Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi Larry

"You should not end your queries with a semicolon in PHP,  as you do when using the mysqli client........." 

Undoubtedly I'm being really fick, but I'm struggling with the above?  I've searched for examples of this advice in script 9.3, but to no avail.

It's from the top TIP in the second column, p280.

Any help much appreciated.

Warm Regards

 

 

Share this post


Link to post
Share on other sites

Hopefully there aren't any examples of queries in PHP scripts having terminating semicolons! Or, put another way, in MySQL you need to use a semicolon to indicate the end of the query to be executed. In PHP you don't need to do this. 

Share this post


Link to post
Share on other sites

Thanks Larry

Lock down fickness.  It's a thing!

 

....so, as an example,  using script 9.7,   p293 (in my book),  line 43.....

             $q = "SELECT user_id FROM users WHERE (email='$e' AND pass=SHA1('$p')) ";

Are you saying that this could/should be written as..

            $q = "SELECT user_id FROM users WHERE (email='$e' AND pass=SHA1('$p')) "            -          without the ending semicolon?

 

 

Thanks again.

                              

 

 

Share this post


Link to post
Share on other sites

Ah, no, not exactly. The semicolon there terminates the line of PHP code. What I'm saying is you don't need to do this:

 $q = "SELECT user_id FROM users WHERE (email='$e' AND pass=SHA1('$p'));";

so that the query being run from the PHP script becomes

SELECT user_id FROM users WHERE (email='$e' AND pass=SHA1('$p'));

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...