Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Empty Variables In 4.2.1+


I have a site where I check to see if a variable isset to see which file I include on a page - the URL would be something like: http://www.domain.com/?s

Then in the PHP file I check to see: PHP Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
PHP Variables Are Always Empty
I'm trying to write a PHP script which allows to enter an username and a
password and to click two buttons.
If I start my PHP scripts 'mytest.php' I see the two input fields and the
two buttons. However if I enter something to the input fields and press a
button the echo commands show nothing.

======

PHP script 'mytest.php'
-----------------------

<?php
session_start();

if (!isset($_SESSION['auth_ok'])) {
$_SESSION['auth_ok'] = false;
}

echo "$user <br>";
echo "$pass <br>";
echo "$button1 <br>";
echo "$button2 <br>";
echo "$auth_ok <br>";

if (isset($button1)){
echo "Button 1 has been pressed<br>";
$auth_ok = true;

Testing For Empty Variables
I am retreiving the results from a randomized multiple choice quiz sent from a another php page using:

foreach($_POST AS $field=>$value){

How do I check to see which questions were not checked?

Empty Variables And 4.21 (POST/GET)
With global variables set to on, I always had the following in my script to make sure variables had a default value:

if (empty($var)) {
$var = 1;}

Now with 4.21, I changed it to:

if (empty($_GET['var'])) {
$var = 1;}

The problem is sometimes I use GET and sometimes I use POST. With global variables on it didn't matter. Now it does. Is there a way to do this? When I try if (empty($_GET['var']) || empty($_POST['var'])), it doesn't work because one or the other will always be empty at any one time.

Empty Variables In Forms
I have some functions that check to see if certain form variables are empty. If they are empty then the function returns a 0. All of that is working just fine. BUT, I cant get the script to see the 0. PHP Code:

Checking For Empty Variables
Can I use empty() to check to see if variables actually have data? Basically I want the script or something to check to see if there is data in the variables. If there is no data, give the user some instructions on writing some data (link to a form or admin panel). If there is data, then continue with writing to the database.

If(empty) Statements/session Variables
1. I have a 2 page form. When the user fills out the info on page form he is directed to the 2nd page of the form. A session variable has been created in the 2nd form to hold all the data from the 1st page. When the 2nd page is submitted all the data (stored from page 1 and new from page 2) are sent to the database.

2. Here is the problem. On page 1, I have several form fields (like combo boxes) that need to work together. For example: I have a text field (name=phylum) in which investigators add new phylum names which are eventually sent to database field "phylum" of the same name. Next to that is a select box (name=newphylum) that has all the names that the investigors have previously entered and that are dynamically retrieved from the database field "phylum".

So when a researcher fills out page 1 of the form he/she can either add a new name or select an already existing name from the select box. But just one of these values can be sent to the database, not both.

QUESTION 1: How can I say and where would I put something that basically says the following: if the phylum text field is left EMPTY (i.e. they don´t add a new name) and they select instead from the select box, that it is the value from the select box and not the text box that gets sent to the database.

QUESTION 2: How do I pass the statement from question 1 into the session variable on page 2 of my form?

Creating Empty Variables For Input Data
I am creating a script that will be taking data from a POST and submitting
the data to variables which are placed within a hash for string to data
association. Then, using HTML::Table and Mail::Sendmail, the data is parsed
into an html table and then an email is created and send to a recipient.
So, my question is this; How do I take the input from a post form and have
the variables pick up the data and process it into a hash?

my $name = ;
my $instock = ;
my describe = ;
# Hash to hold inventory data
my %table_data = (
model ='$modelnumber',
item ='$name',
available ='$instock',
description ='$describe',
);

This is all the code I have written thus far, any pointers or suggestions
for this project?

Firefox Causing Empty PHP Form Variables??
This is really weird, and I would never believe it possible if it
weren't actually happening to me.

I've a customer database in mySQL, using PHP to create the forms, yadda
yadda.
All of a sudden, every time I edit a customer, when I submit the form
using Firefox 1.0.2 on Linux (Fedora Core 3) it sends empty form fields
to the database.

BUT, if I use Firefox on Windows, or Opera on Fedora Core 3, it works
perfectly fine.

Any ideas what in the world could cause this?
Firefox on Linux worked fine to up until...the last few days I think.
The only think I can think of, is I may have installed a couple of
extensions during that time.

Ftp_nlist Returns False For Empty Directory Instead Of Empty Array
In an application installed with PHP5 it looks like ftp_nlist() returns
false if the directory is empty, instead of an empty array as it should
according to the manual. On the original server with PHP4 it works as
expected.

Is this a bug, or an undocumented change in PHP5, or a setting that
could be changed somewhere?

PHP Session Is Empty And Session File Is Empty
I am trying to save a SESSION variable which looks to succeed because right after I print it out to verify it. I do so as follows:

session_start();
<snip>
$_SESSION['security_code'] = $code;

The problem is that I submit a form on the same page and I need to check if the $_SESSION['security_code'] == $_POST['security_code'] however this condition is always false because $_SESSION['security_code'] is empty.  I also checked the security files that are created in the PHP 'save_path' directory and it appears to be creating an empty session file.

Can anyone suggest anything here?  Also prior to the condition, I also do a session_start() and that doesn't help either.

I got this code from a open source area and on that web site, if I test it it works fine.  On my localhost it does not work.  I'm not sure if I'm missing some configuration or whether PHP 5.2.2 has problems with sessions.

Using Empty And &&
Im checking to see if all of these are empty I have to do something:

if (empty($_POST['phhome'] && $_POST['phcell'] && $_POST['phwork'] &&
$_POST['email'])) {

But this isnt working and putting empty() around each didnt either. What
I'm I not seeing?

Help With Empty()
this is my php:

$pro1=addslashes($_POST['pro1']);
$pro2=addslashes($_POST['pro2']);
$pro3=addslashes($_POST['pro3']);
$pro4=addslashes($_POST['pro4']);
$pro5=addslashes($_POST['pro5']);

for ($i=1;$i==5;$i++){
if (!empty(${'pro'.$i}))
$pros.=${'pro'.$i}."";
}
echo nl2br($pros);

$pros return nothing, although $pro1 and $pro2 contain certain value...

Using If Empty
I am trying to use the if empty statment to make sure that every input box has been filled, the code looks like this. Code:

if(empty($inputbox)){
print "you did not fill in a box.";}

This works fine but there is about 20 input boxes and there must be an easier way to insted of repeating this 20 times.

Empty If / Else ?
I have never done this, but I have an if/else statement, and if I don't want anything to happen in the if statement, should I leave it empty or is there something that I could add???

A simple example (my actual code is much longer):
<?php
if(empty($_POST['fname'])){

}else{
     $name = $_POST['fname']
     mysql_query("INSERT INTO name(`first`) VALUES ('$name'));
}?>

Testing For Empty Set?
basically, i want to query my db and see if the user has input a valid #.... if it matches a record im my table 'plu_coupons' then i will execute the code that allows a user to proceed... if the number input by the user does not match any of my records, he/she will be redirected to the sign-in page...

How To Empty An Array?
I've got a nested array, which I populate while processing and formatting results from a query. When I print the contents of the array I want to clear it so that I can use it again in the next iteration of the loop without the stuff I've printed still in it. Is there a straight forward way to do this? I've tried re-declaring it but that doesn't empty it.

Empty Sessions
When sessions are created by my message board or any other script. The sessions I can see inside the /tmp folder but when I open em up with pico I see NOTHING! no session variables or anything!!

I have been tryin to figure this out forever here is my php.ini configuration for sessions

[Session]
session.save_handler = files ; handler used to store/retrieve data
session.save_path = /tmp ; argument passed to save_handler
; in the case of files, this is the
; path where data files are stored
session.use_cookies = 1 ; whether to use cookies
session.name = PHPSESSID
; name of the session
; is used as cookie name
session.auto_start = 1 ; initialize session on request startup
session.save_handler = files ; handler used to store/retrieve data
session.save_path = /tmp ; argument passed to save_handler
; in the case of files, this is the
; path where data files are stored
session.use_cookies = 1 ; whether to use cookies
session.name = PHPSESSID
; name of the session
; is used as cookie name
session.auto_start = 1 ; initialize session on request startup
session.cookie_lifetime = 0 ; lifetime in seconds of cookie
; or if 0, until browser is restarted
session.cookie_path = / ; the path the cookie is valid for
session.cookie_domain = ; the domain the cookie is valid for
session.serialize_handler = php ; handler used to serialize data
; php is the standard serializer of PHP
session.gc_probability = 1 ; percentual probability that the
; 'garbage collection' process is started
; on every session initialization
session.gc_maxlifetime = 1440 ; after this number of seconds, stored
; or if 0, until browser is restarted
session.cookie_path = / ; the path the cookie is valid for
session.cookie_domain = ; the domain the cookie is valid for
session.serialize_handler = php ; handler used to serialize data
; php is the standard serializer of PHP
session.gc_probability = 1 ; percentual probability that the
; 'garbage collection' process is started
; on every session initialization
session.gc_maxlifetime = 1440 ; after this number of seconds, stored
; data will be seen as 'garbage' and
; cleaned up by the gc process
session.referer_check = ; check HTTP Referer to invalidate
; externally stored URLs containing ids
session.entropy_length = 0 ; how many bytes to read from the file
session.entropy_file = ; specified here to create the session id
; session.entropy_length = 16
; session.entropy_file = /dev/urandom
session.cache_limiter = nocache ; set to {nocache,private,public} to
; determine HTTP caching aspects
; cleaned up by the gc process
session.referer_check = ; check HTTP Referer to invalidate
; externally stored URLs containing ids
session.entropy_length = 0 ; how many bytes to read from the file
session.entropy_file = ; specified here to create the session id
; session.entropy_length = 16
; session.entropy_file = /dev/urandom
session.cache_limiter = nocache ; set to {nocache,private,public} to
; determine HTTP caching aspects
session.cache_expire = 180 ; document expires after n minutes
session.use_trans_sid = 1 ; use transient sid support if enabled
; by compiling with --enable-trans-sid

PLEASE I NEED HELP!!

my /tmp is chmoded to 777 and I have tried everything...

I know it isnt my forums because they worked on another server I transfered from and also it affects more than just the forums... every scripts that uses sessions is affected...

Empty Array?
I have a query that selects some data from a table based on the current ID
selected.

If the query does not return any results, I want it to continue to another
query that will insert a record into the table.

Below is what I have...but it will not insert anything if the first query...

PHP_AUTH_USER Is Empty
I use basic authentication in Apache. I like to use the global variable
$_SERVER['PHP_AUTH_USER']. Unfortunately this variable is empty/no
availabe. Same with PHP_AUTH_PW. AUTH_TYPE is working and states
"Basic".

Php Shows Up Empty
I havea problem with a php page, everytime I call it it presents me
with an empty page, with only

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-
1252"></HEAD>
<BODY></BODY></HTML>

as if have only made an empty php-page, I cannot figure out what the
problem is, can anyone help me. (I have made a test page with only <?php ?> run it and it gave me the exact same result)

Htaccess Must Be Empty
I am moving some php scripts to a new host. While getting to know the
server, I ran into a strange problem.

If I add a .htaccess file, or more specifically: a .htaccess with
content, to a folder, requesting (html and php) files from that folder
results in internal server error messages.
If I upload an empty .htaccess file, all is fine. Then phpinfo() tells
me I am using Apache/1.3.27.

$_POST Of Empty Vs 0 Value
working on LINUX I found that both empty($_POST['foo']) where $foo = 0 or &foo = empty gives me TRUE. I.e. I can not distingush between 0 and empty value - I need it for the text box value. What is the solution?

Empty The Database
Is there a command that will empty or delete all the information in a database but keep the structure of the database so new information can be added to it?

Empty Lines
i read the filr into an array using file().
some of the lines are empty. i would like to output the file but
ignoring the emnpty lines.

Empty Form
Say I have a form, a really long form, is there a way to check if all the fields in the form are empty without saying a million if statements?

Empty Vs. Isset
I have a user form where users input float values or integers. If I want to see if no value has been input, I use the empty() function.  But if I want to see if users HAVE input a value that is a float or an integer, what function should I use?

How To Empty An Array??
I have an array being created a number of times with in a loop, before it is created I want to check if it empty and if it isn't then clear it down. How do I do this?

If Statement And Empty
i have my form and what i want to happen is when ALL the values are not empty i want to process the form but if just one of the values is empty i want top redisplay the form i have 15 values in my form, i know thats quite a lot but i need them all
so how would i do this? Code:

Using If Empty With Two Items
I am trying to say if $_Post and $_Session are empty set the variable $dcparent to equal 1, but it doesn't like what I am doing. 

if(isset($_POST['dcparent'])) {
$dcparent = mysql_real_escape_string($_POST['dcparent']);
}

if(isset($_SESSION['dcparent'])) {
$dcparent = mysql_real_escape_string($_SESSION['dcparent']);
}

if(empty($_POST['dcparent']) && (empty($_SESSION['dcparent'])) {
$dcparent = 1;
}

Empty Query
How can I tell if a query is empty:

I need to test this

$get_buddys = mysql_query($query_get_buddys) or die ("Invalid query". mysql_error());

Sessions, Tmp Dir, Empty Files
Problem - the /tmp session files created in my tmp directory contain zero bytes (ie. totally empty). Any ideas why?

Here's my setup: Windows 2000, Apache web server, PHP402. I can see new session files being created each time a new session is registered, but they're not much use if they're empty! I've checked the file permissions on the tmp directory, and it's completely shared out. No error messages or logs are being generated that I'm aware of.

Thanks for any help...

Empty Arrays Or No Files
I have written a script which depending on the variable uploads $num files.
The value of $num is stored in a mysql column and each file is uploaded in an array $file[], then placed in a directory by the name $id_$i.jpg (for example).

The problem arises when I want to display the files back in a table. The $num is read back through the mysql query and if the amount of files is less than $num then I have a partially filled table. The cells with no filename display the icon which references "no image" as there is no file in the upload directory to reference.

What I would like to know is

1)if when the form is submitted and only half of the files are uploaded could I set the array so it realises that only half of $file[] has been filled, or that only 6 of 12 files have been uploaded.

2) Alternately, could I count the number of files in a directory on my server and store that value as an variable to set the number of columns in my table?

What would be the code for this???

Thanks in advance.

Check If Directory Is Empty
I've made a script that puts images in a certain directory into the database. With the following code.

How Do I Not Print Something Out If A String Is Empty?
I am using mySQL to get stuff from a database, the fields are getting parsed into the variables $no , $t , $a , $l and $y

At the moment I am using this line this to display them to the web browser;

echo "$no: $t - $a [$l] ($y)<br>$n<br><br>";

However, sometimes $y is empty when the SQL query returns it's result and so if that happens I get something like

2000: blah - blah [whatever] ()
blah blah blah

Is it possible to add some code to my echo line that only outputs the () if $y is not empty?

I am sure this is possible but I havn't got a clue how to do it.

Empty Attachement Through Mail()
can someone check my code for me to see where I went wrong please?

I have made a short page where people can enter an email address and select a file to be sent to them. I have pillaged some code from some previous posts here which was very helpful. The script works more or less, however I have 2 problems:

1) The HTML isn't picked up in the body of the email, however the text is.

2) The attachment makes it to the email however when you open it up, its a blank file. The file name and size are correctly reported in the atachment.

Here is my code. I've also made sure the selected files are 777 on the server. If someone could take a quick gander, I'd really appreciate it!

I Was Confused Between Isset() And Empty()
What's the diff between function isset() and empty()? I was totally confused.

I create a table with mysql as:

How Can I Empty A File's Content?
I uses fopen and fwrite to write a file called "dummy.txt". I would like to empty it everytime I want to write a new content. How can I empty the content of the file?

I've tried using unlink() but I seems to have permission problem with my server. I am guessing that I can't delete a file.

Checking If A Directory Is Empty.
if there an easy way to determin if a Directory is empty or not?

Empty Fields For Every Record
If i have a table structure like in my attachment, how can i check for empty fields.That is, I want to check for every record in the table if lastname, street, zip, city and pwd are filled.

For example, in the second record that is with id no:2, street and city are empty.Similarly for the next record with id no:3, lastname,zip and pwd are empty.

So, idno:2 and idno:3 are incomplete.
Now, what i would like to do is, if i press a button, i want to send an e-mail to the respective e-mails which are in idno:2 and idno:3 that they need to fill their information again.

Could somebody please tell me how can i do this one?

Empty $_SERVER['HTTP_USER_AGENT']?
On several of my pages using this value, although Im not checking if it exists (which i think is most of my problem). When the function is called that uses this value, i get error log email, reporting that
"Undefined index: HTTP_USER_AGENT"

on the line number that the $_SERVER variable is used.

What should I do if something (web crawler possibly?) is hitting my website and not reporting a user agent. Im tempted to just do a redirect if this value isnt set.

$_POST Is Empty (in MSIE?)
Has any of You ever experienced the problem that posted forms deliver an
empty $_POST-array?

I have a form like:

<form method="POST" action="https://.../result.html?qid=70">
<input type="checkbox" value="1" name="1a">
<input type="checkbox" value="1" name="1b">
(...)
<input type="submit" name="Answer" value="Answer">
</form>

and every once in a while I get empty results (1 out of 10, maybe). This
only happens in MSIE 6.0, as far as I can see, but I'm not absolutely sure.
Some users have the problem all the time, some never.

I use https to connect and mod_rewrite to rewrite "result.html" to
"result.php"...

SERVER_SOFTWARE:
Apache/1.3.27 (Unix) PHP/4.3.1 mod_ssl/2.8.12 OpenSSL/0.9.6g

Code Problem When Empty
I am having problems with adding this code to authentication PHP Code:

Empty Fields In Forms
I'm working on a script for a form for people to submit their info ( Name, e-mail, AIM, website URL etc). Now it is possible that some people don't have AIM or a website. I'm using a html table to display the info on the member page and empty fields make the table look strange. Is there a way to set some default value (like N/A) that would be displayed in case a field is left empty?

Mysql Empty Table
does anyone know what the mysql comand to empty and table?

Empty Cell In MySQL
How do I output the HTML code &nbsp; if a cell in MySQL has no data in it?

How To Check Empty Fields
If i have a table structure like in my attachment, how can i check for empty fields.That is, I want to check for every record in the table if lastname, street, zip, city and pwd are filled. For example, in the second record that is with id no:2, street and city are empty.Similarly for the next record with id no:3, lastname,zip and pwd are empty.

So, idno:2 and idno:3 are incomplete. Now, what i would like to do is, if i press a button, i want to send an e-mail to the respective e-mails which are in idno:2 and idno:3 that they need to fill their information again.

Session Tmp Files Empty
I have PHP 4.0.6 (I'm stuck with this till I can find a hosting company that realizes that upgrading would be a good idea) and I have this simple test:

In "test1.php"
<?
session_start();
$HTTP_SESSION_VARS['test'] = "hey";
header("Location: test2.php"); ?>

In "test2.php"
<?
session_start();
var_dump($HTTP_SESSION_VARS);?>

It prints an empty array. So I logged int via telnet and looked at the session files in /tmp and they are all empty and have a file size of 0.

Checking An Array If Empty!
i have an array wich i want to compare if it's empty ( wich means no text or numbers or tokens ) i thought that could be done with the following! Code:

$_SESSION Comes Empty On Next Page
I am not able to find the solution to this problem :(.
I have two php pages . On the first page i am getting some values in
$_SESSION when i use print_r function. I don't get the values when i
use just echo() or print() functions.
Now, the first page calls the second php page. But when i try to get
the values for $_SESSION on the second page i get empty values even
when i use print_r() function.
register.globals is set to on in php.ini. I am also using
start_session() on these pages but to no effect.


Copyright © 2005-08 www.BigResource.com, All rights reserved