Jump to content

Mysql Query Code Help.


Hypersource

Recommended Posts

heres my code:

 

 

 

$sql="

INSERT INTO `a8392424_pets`.`users` (

`user_id` ,

`user_name` ,

`user_pass` ,

`user_email` ,

`user_date` ,

`user_level` ,

`posts` ,

`married` ,

`cash` ,

`tokens`

)

VALUES (

NULL, '" . mysql_real_escape_string($_POST['user_name']) . "', '" . sha1($_POST['user_pass']) . "', '" . mysql_real_escape_string($_POST['user_email']) . "', NOW(),'0', 'noone', '10000', '10')";

$result = mysql_query($sql);

if(!$result)

{

//something went wrong, display the error

echo 'Something went wrong while registering. Please try again later.';

//echo mysql_error(); //debugging purposes, uncomment when needed

}

 

 

When I execute it, using my signup form, the query fails. my connection to database is GOOD.

Edited by Hypersource
Link to comment
Share on other sites

As mrMarcus said.

 

user_id is probably an auto increment field, so you can delete the line

 

`user_id` ,

 

 

if it still doesn't work, uncomment

 

"//echo mysql_error(); //debugging purposes, uncomment when needed".

and comeback with a decent error message.

 

it even says right there. "debugging purposes. uncomment when needed".

Edited by play_
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.