Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Valid MySQL result 1

Status
Not open for further replies.
sound slke the sql is wrong to me - know way of knowing without the script!
 
Try adding this after the mysql_query() part...

$error = mysql_error();
if ($error) { echo "Error: $error"; exit; }

Cheers

Andy
 
This is the error I get now Andy:

Error: No Database Selected

Any ideas thanks for the replies

Jahjah
 
Have now solved the problem, I was connecting to mySQL with a user that wasnt able to run php - now have it working fine

Thanks anyway

Jahjah
 
in which case, theres the problem!

when using mysql, not only do you connect to the server, you have to tell it which database to use before you can start firing sql commands at it

above your sql code, put in
mysql_select_db("dbname");

you should have the dbname from when you or whoever setup mysql initially
 
Also:

Save yourself some time and aggravation by adding error checking for each mysql command:
Code:
$cp = mysql_connect($host,$user,$pass) OR die(mysql_error());
mysql_select_db($dbname, $cp) OR die(mysql_error());
etc.

When you catch the actual error right where it happens you will not have to start searching back from an effect that is caused way before it happens.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top