Error with MySQL

O

old.Mozzer

Guest
Im using:

$query = "SELECT * from $tableproperties WHERE group='1'";

$result = mysql_db_query ($dbname, $query, $link);

$total_sale = mysql_num_rows($result);

however I keep getting:

Warning: Supplied argument is not a valid MySQL result resource in /home/jmorris/public_html/sites/steve.morris/i_properties.phtml on line 21
 
O

old.Jas

Guest
I'm no PHP expert (ASP on the other hand ;))but don't you need to concatenate those variables? I guess it would be summit like

Code:
$query = "SELECT * from " & $tableproperties & " WHERE group='1'";
 
L

Louster

Guest
No, PHP sorts out variables fine when they're within double-quote strings... Uhm. I'm guessing there's some problem, and it returns NULL or something. Perhaps do a check after the query?
 
L

Louster

Guest
... But that was probably really obvious. Uhm. There's a function for printing out the error text from the last MySQL query:

Description

string mysql_error ([resource link_identifier])


Returns the error text from the last MySQL function, or '' (the empty string) if no error occurred.



Bung a print statement with that in after you've tried the query perhaps?
 
T

Teaser

Guest
What is $tableproperties in that query ?
 
T

Tempy_Incursion

Guest
$tableproperties seems to be a variable containing the name of a DB table, I never use these just the actual name of the table in queries but I doubt it makes much difference.
 
T

Teaser

Guest
Yus, I assumed this was the name of a table, but calling it tableproperties didn't make sense, hence I'm asking what it is.

$link = mysql_connect ("address", "username", "pass") ;
mysql_db_select ("name_of_db", $link) ;

$query = mysql_query ("select blah from blerugh where group = 1", $link) ;

$blah = mysql_num_rows ($query) ;
 

Users who are viewing this thread

Top Bottom