Jump to content

PHP Update Giving me MySQL Errors.


novumorganon

Recommended Posts

So I have a site for dealing with proprietary issues for my business. Coded it years ago as a website, due to folks working for me from home. Now my servers are forced into the new PHP update, 7.4 I think, and I'm getting this rather vague error:

 

Fatal error: Error executing query: SELECT ca.customer_id, aa.needs_checking, c.agent_id FROM customer_accounts ca, allowed_accounts aa, customers c WHERE aa.allowed_acct_id = ca.account_type AND c.customer_id = ca.customer_id AND ca.is_active =1 AND ca.mail_interval !=0 AND ca.next_check < UNIX_TIMESTAMP() AND aa.needs_checking=1 AND c.word_balance > 150 AND c.agent_id= - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 in /home/customer/www/i-scribes.com/public_html/mysqldb.class.php on line 270

For this line of code:

 

        $sql = "SELECT ca.customer_id, aa.needs_checking, c.agent_id FROM customer_accounts ca, allowed_accounts aa, customers c WHERE aa.allowed_acct_id = ca.account_type "
                . "AND c.customer_id = ca.customer_id AND ca.is_active =1 AND ca.mail_interval !=0 AND ca.next_check < UNIX_TIMESTAMP() AND aa.needs_checking=1 AND c.word_balance > 150 AND "
                . "c.agent_id={$_SESSION['staff_id']}";

        $db->executeQuery($sql);

If anyone can help, it would be most appreciated! <3

Link to comment
Share on other sites

the error is because the session variable doesn't contain a value.

so, two things -

  1. code should ALWAYS validate inputs before using them. if a required input isn't valid, that's an error and the code should setup and display a message for the user telling them what is wrong and not attempt to use the input.
  2. you need to determine why the session variable doesn't contain an expected value. either it's not being set or it is being lost somewhere along the way.  based on the name of that variable, this either has something to do with the user authentication/login system or a user permission system. do other things requiring user authentication/permissions work?

there should be other php errors that will help pin point where the problem is starting at. is php's error_reporting set to E_ALL?

beyond that, it would take having the code where that session variable is being set at through to the posted code in order to come up with specific things to look at.

Link to comment
Share on other sites

3 minutes ago, mac_gyver said:

the error is because the session variable doesn't contain a value.

so, two things -

  1. code should ALWAYS validate inputs before using them. if a required input isn't valid, that's an error and the code should setup and display a message for the user telling them what is wrong and not attempt to use the input.
  2. you need to determine why the session variable doesn't contain an expected value. either it's not being set or it is being lost somewhere along the way.  based on the name of that variable, this either has something to do with the user authentication/login system or a user permission system. do other things requiring user authentication/permissions work?

there should be other php errors that will help pin point where the problem is starting at. is php's error_reporting set to E_ALL?

beyond that, it would take having the code where that session variable is being set at through to the posted code in order to come up with specific things to look at.

So I think you are right with there being something wrong with sessions. I'm guessing PHP 7 had some updates to how sessions work too? Le sigh, this may not be as easy as I thought. Lol. Thank you for the fast help everyone! Appreciated.

Link to comment
Share on other sites

4 minutes ago, novumorganon said:

I'm guessing PHP 7 had some updates to how sessions work too?

no. the most likely thing is php's output_buffering setting being previously ON, but now it is off, preventing things like the session_start() from working, combined with bad code not doing things like halting php execution following header redirects. there would be php errors.

Link to comment
Share on other sites

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.