<?php
$connect = mysql_connect($host, $user, $pswd) or die("Could not connect: " . mysql_error());
print ("Connected successfully");
mysql_select_db("tech support");
print ("<br />We'r on tech support now ");
$query = mysql_query("SELECT 'id' FROM 'clients' WHERE 1");
print ("<br />query done");
$num_rows = mysql_num_rows($query);
print ("<br />num_rows is --> $num_rows");
mysql_close($connect);
print ("<br />Connection over");
?>
but when i run my code that what s i get
Connected successfully
We'r on tech support now
query done
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in d:\program files\easyphp\www\tech_support\db.php on line 25
I tried it but no it doesn't work..
what s bizzar it s i can connect
i can choose my DB
i can call a query
but when i try to get info (num_row for exemple)
it give me the error...
i think it might be something i have to setup (permission or something maybe)
<?php
$connect = mysql_connect($host, $user, $pswd) or die("Could not connect: " . mysql_error());
print ("Connected successfully");
mysql_select_db('tech support') or die(MySQL_Error());
print ("<br />We'r on tech support now ");
$sql = "SELECT id FROM clients WHERE id = '1'";
$result = mysql_query($sql) or die(MySQL_Error());
print ("<br />query done");
$num_rows = mysql_num_rows($result);
print ("<br />num_rows is --> $num_rows");
mysql_close($connect);
print ("<br />Connection over");
?>
anyways, if this doesn't work then you don't have your table setup correctly, or you aren't connecting to the db. try those error codes i put in the code and see if you get anything back.
hehe i did not express myself properly
i know in the code i submitted i did have a space.. but i changed it on my computer..but it still didn t work...
so basically it s was irrelevent for my to pin point the change..
Table and field names should be enclosed in backticks (`), not in single quotes (').
MySQL manual wrote:
Note that the rules changed starting with MySQL Version 3.23.6 when we introduced quoting of identifiers (database, table, and column names) with `.
" will also work to quote identifiers if you run in ANSI mode. See section 1.7.2 Running MySQL in ANSI Mode.