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...

Link to comment
Share on other sites

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()."' )";

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.