0

The exact error message is:

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 'where rfflag='0'' at line 1

Hi,

I'm trying to get some php scripts working and it dies with the above error message. There are two locations where rfflag is used in the SQL query:

$_SESSION['lang']=$objTerm->my_get_one("select min(id) from "
    .$objTerm->TABLE['languages']." where status='1' and rfflag='0'");

$rs_lang=$objTerm->execute_query("select id,language from "
    .$objTerm->TABLE['languages']." where `status`='1' and `rfflag`='0'");

How do I determine which one is causing the problem? Or is the problem something else altogether?

1
  • Are you 100% sure that rfflag isn't used in another query somewhere? Commented Sep 16, 2010 at 6:42

4 Answers 4

2

Echo this:

"select id,language from ".$objTerm->TABLE['languages']." where status='1' and rfflag='0'"

and this:

"select min(id) from ".$objTerm->TABLE['languages']." where status='1' and rfflag='0'"

Then run execute each output in your favorite sql developer tool. Errors will be displayed there.

Sign up to request clarification or add additional context in comments.

Comments

1

How do I determine which one is causing the problem?

Remove one of the queries. See if it still happens.

On a secondary thought, I would suggest that you change your MySQL query code so, that it doesn't use die() to print out the error message. Use trigger_error or exceptions instead, this way you will automatically get a trace of which line caused it.

Comments

0

How do I determine which one is causing the problem?

use trigger_error() to output an error message.
I guess (I have to guess because you supply no code) that you are using die() to output an error.
if you change this bad practice function to trigger_error(), you will be able to see the line number, where error occurred.
If you add non only mysql_error() to it's output, but also query itself, you will be able to see the problem code too.

Comments

0

I guess $objTerm->TABLE['languages'] is undefined or does not have the value you’re expecting.

As sheeks06 has already suggested, just echo the query to see if everything is as expected:

$query = "select min(id) from "
    .$objTerm->TABLE['languages']." where status='1' and rfflag='0'";
echo $query;
$_SESSION['lang']=$objTerm->my_get_one($query);

$query = "select id,language from "
    .$objTerm->TABLE['languages']." where `status`='1' and `rfflag`='0'";
echo $query;
$rs_lang=$objTerm->execute_query($query);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.