Page 1 of 1

get error in php, but goes fine in phpMyAdmin

Posted: Sun Apr 27, 2003 3:13 am
by Sevengraff
Ok, i'm getting a big headache from this.

Ok, im using a small template thing on my script. I keep the HTML for it in MySQL, and i use this query to get it out:

Code: Select all

SELECT value FROM sn_config WHERE name='skin'
Now, when I run something like

Code: Select all

mysql_fectch_object(mysql_query("SELECT value FROM sn_config WHERE name='skin'"))
i get

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource

However, I can run that same query in phpMyAdmin and not get any error at all. Plus, when i try to print mysql_error() or mysql_errno() nothing will be outputted.

I am extreamly confused. Why is it working in one place, and not another? I also am wondering why there is no error message from MySQL.

Posted: Sun Apr 27, 2003 3:44 am
by twigletmac
Instead of putting those two function calls together like:

Code: Select all

mysql_fectch_object(mysql_query("SELECT value FROM sn_config WHERE name='skin'"))
try separating them out and changing it to:

Code: Select all

$sql = "SELECT value FROM sn_config WHERE name='skin'";
$result = @mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
$row = mysql_fetch_object($result);
Mac

Posted: Sun Apr 27, 2003 8:55 pm
by Sevengraff
I tried that, and it gives me an error on the line with the mysql_fetch_object().

Posted: Mon Apr 28, 2003 1:58 am
by twigletmac
What is the error you get?

Mac

Posted: Mon Apr 28, 2003 7:53 am
by praveen
you should give semi colon(;) at the end of the select statement.


mysql_fectch_object(mysql_query("SELECT value FROM sn_config WHERE name='skin'";));

Posted: Mon Apr 28, 2003 11:02 pm
by Sevengraff
I've found the problem. The class I was using to handel my sql stuff wasn't displaying mysql_error() correctly, and i wasn't connecting to the right database. thanks for your help, but it was just my fault.