Jump to content

Recommended Posts

can anyone tell me why the following code isnt working?

 

$sql = mysql_query("INSERT INTO users (tracknum, username, address, state, city, phone, fax, email, groupn, isdone) VALUES('$tracknum', '$username', '$address', '$state', '$city', '$phone', '$fax', '$email', '$groupn', '$isdone')")  or die (mysql_error());

 

I know all the variables exist before that statement.

Is there anything else it can be? Im not getting any error codes or anything. only this...

 

if(!$sql){

    echo 'There has been an error creating your account.';

}

 

Has anyone got any ideas of what it could be or how to get some more useful error messages?

Link to comment
https://forums.phpfreaks.com/topic/55254-mysql-insert-not-working/
Share on other sites

  • 2 weeks later...

I am assuming that this is a MSSQL server you are connecting to so you need to change the mysql to mssql.

You can also try to remove the () for the column names

 

INSERT INTO users tracknum, username, address, state, city, phone, fax, email, groupn, isdone VALUES ('$tracknum', '$username', '$address', '$state', '$city', '$phone', '$fax', '$email', '$groupn', '$isdone')") 

 

finally, if any of your fields are of type int then you will need to remove the ' ' for the values.

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.