Jump to content

Recommended Posts

I did, and the both seem to work. Just I am having some issues that should not be happening because I have a code in place to prevent it. But the difference is...see above

 

I just want to know that one browser does not see it differently (or ignore it) than other..

I just want to know that one browser does not see it differently (or ignore it) than other..

PHP is SERVER side and all it does is create files for the browser to then interpret.  The actual php functions will NOT change from browser to browser.  However the output created by php could be interpreted different from one browser to another.

What is the difference between writing

 

if ($_POST['something'] == "" ) echo "that";

and

if ($_POST[something] == "" ) echo "that";

 

and would it have any effects?

 

PHP will throw a warning and waste time as it first tries to interpret the unquoted array index as a constant, then finally decides that since no constant by that name exists it should be treated as a string. If you had error reporting on, you'd see that.

PHP treats undefined constants as strings. Up your error reporting level and you'll see that the second example is actually horribly wrong.

 

Another example is:

 

echo FOO . PHP_EOL;
const('FOO', 'bar');
echo FOO . PHP_EOL;

 

Will output:

 

FOO

bar

Here's a monkey wrench thrown in -

 

I'm going to guess that in your actual code you are having a problem with, someone used a defined constant for the array index name and in the case where you put the quotes around it, your code actually stopped working?

 

A more reasonable answer: As already suggested, you should be developing and debugging your code on a system with error_reporting set to E_ALL (or to a -1) and display_errors set to ON so that you would be seeing all the errors that php detects.

The code works fine 98% of the time. It is just that 1 out of 50 something happens and I am not sure why:

 

I have a project registration form where you have to enter first students name. Than you have an option "is there a second student? Yes - No" No is selected by default. If they click yes fields are un-disabled and second student info can be entered. Same thing for third. If they select yes and enter no student, or enter no first student, or if their java scrip is off and they keep no and enter student name, PHP will tell them to fix it. I believe I am covered on that well.

 

In post processing I have a code that looks and see if second/third name are blank and if they are it assigns value of 'nostudent' to those appropriate blank fields.

 

Most of the submissions got processed OK, but I had one second and third name in the database that were blank, but 'nostudent' was not entered there. (and selections for both second/third student were NO) So I assigned default value in database for second and third names to be 'nostudent'.

 

Again most for the submissions went fine, and that again I got one where second and third name in the database were blank, but 'nostudent' was not entered there (and selections for both second/third student were NO). So, I added extra feature to code and told it if second/third names are blank or if the selection for second/third are NO, assign value of 'nostudent' to those appropriate blank fields. Keep in mind that if they select yes and enter nothing or vice versa they get error.

 

Again few went fine and I got one this morning. Hence my original question

 

P.S.

As I was typing this I got in 12 registrations, all fine.

 

that the default value on the DB was over written meens that something is happening that is assigning a value to these second and third students.  Have you checked what happens if you choose yes to additional students, fill in some info, and then change it back to no again for the final submition?

Works fine (well for me). I have even entered three spaces for third and and I do got 'nostudent' in DB. And still if you select no for second/third student (even if you put a name in with javascript off)  PHP is instructed to give you an error. On top of that it is also instructed at the end to put 'nostudent' in the fields if NO is selected for second/third student.

 

Oh, and there is no other thing that  has write privileges to this table, so that form is the only one.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.