fumble Posted May 12, 2020 Share Posted May 12, 2020 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 Link to comment Share on other sites More sharing options...
Larry Posted May 13, 2020 Share Posted May 13, 2020 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. Link to comment Share on other sites More sharing options...
fumble Posted May 14, 2020 Author Share Posted May 14, 2020 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. Link to comment Share on other sites More sharing options...
Larry Posted May 15, 2020 Share Posted May 15, 2020 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')); Link to comment Share on other sites More sharing options...
fumble Posted May 17, 2020 Author Share Posted May 17, 2020 Ahhhh, I see what you are saying now. Thank you Link to comment Share on other sites More sharing options...
Recommended Posts