query works in phpmyadmin but not from my code[Solved]

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: query works in phpmyadmin but not from my code

Post by Benjamin »

Ok, I found the problem. I never use OR and didn't realize it could affect return values.

Change

Code: Select all

function SendQ($query)
{
  return mysql_query($query) or die(mysql_error());
}
To

Code: Select all

function SendQ($query) {
    $result = mysql_query($query);
    if (!$result) die(mysql_error());
    return $result;
}
[text]root@midnight:# php -r 'echo var_dump(4 OR false);'
bool(true)
[/text]
User avatar
KrypticNinja
Forum Newbie
Posts: 16
Joined: Thu Mar 18, 2010 6:14 pm

Re: query works in phpmyadmin but not from my code

Post by KrypticNinja »

Thank you so much for all your help. I'm not sure I'd have ever figured that out, ha ha.
Post Reply