Jump to content

[SOLVED] simple Insert works on mySQL 5 not on 4??


amites

Recommended Posts

began testing this script on server and running into a new snag,

 

	$query = "INSERT INTO bil_location (state_id, city_id, name, description, street, zipcode, entered)"
	. "\n VALUES ('".$locstate."', '".$loccity."', '".$locname."', '".$locdesc."', '".$locadr."', '".$loczip."', now() )";

 

only error I get is: mysql_error

 

almost certainly syntax but I'm not sure where to go with it...

Try this

 

$query = "INSERT INTO bil_location (state_id, city_id, name, description, street, zipcode, entered)"
	. "\n VALUES ('".$locstate."', '".$loccity."', '".$locname."', '".$locdesc."', '".$locadr."', '".$loczip."','". now()."' )";

 

Also, post the code that is executing the mysql_query() and is outputting: "mysql_error". Perhaps that code is not echoing correct and useful information and can be improved to get it to tell what the problem actually is.

 

Based on what you have posted, this could be anything from a mysql server problem/no connection, no database selected, no mysql extension installed, a syntax error, a typo or wrong table or column name.

I had talked my client into using a mySQL 5 server,

 

though this still bothered me so I came back and looked at the code,

 

noticed that I didn't have it set to echo out an error just execute the query

 

$result = mysql_query($query);

 

changed that to

$result = mysql_query($query) or die(mysql_error);

 

and now it works on mySQL 4, didn't change anything else

 

strange...

 

many thanks for taking the time to try and help

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.