Jump to content

[SOLVED] MySQL Problem


pudge1

Recommended Posts

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' I keep getting that error whenever I try and run my script. Here is my script:

 

$my = mysql_connect("localhost","nintendo_pudge","*****");

if(!$my)

{

echo "Failed to Connect to MySQL Database<br />";

echo mysql_error();

exit;

}

else{}

 

 

$con2 = mysql_select_db("nintendo_urlblurusers", $my);

 

if(!$con2)

{

echo mysql_error();

exit;

}

else

{

}

 

$var = "CREATE TABLE Users

(

userID int NOT NULL AUTO_INCREMENT,

PRIMARY KEY(userID),

Username varchar(15),

Password varchar(15),

Email varchar(35),

AccountType varchar(10),

PayPalEmail varchar(35),

)";

 

$con3 = mysql_query($var,$my);

if(!$con3)

{

echo mysql_error();

exit;

}

else

{

}

 

$con4 = mysql_query("INSERT INTO urlblur_users (Username,Password,Email,AccountType,PPEmail)

VALUES ($username,$password,$email,$atype,$ppemail)");

 

if(!$con4)

{

echo myql_error();

exit;

}

else

{

}

 

mysql_close($my);

 

Anyway I am really new to MySQL this is my first MySQL form I have started. I am really good with PHP though.

Link to comment
Share on other sites

$var = "CREATE TABLE Users
(
userID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(userID),
Username varchar(15),
Password varchar(15),
Email varchar(35),
AccountType varchar(10),
PayPalEmail varchar(35),
)";

 

change to

 

$var = "CREATE TABLE Users
(
userID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(userID),
Username varchar(15),
Password varchar(15),
Email varchar(35),
AccountType varchar(10),
PayPalEmail varchar(35))";

Link to comment
Share on other sites

Fixed that problem thank you for that. But now I get this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@yahoo.com,free,)' at line 2

Link to comment
Share on other sites

$my = mysql_connect("localhost","nintendo_pudge","*********");

if(!$my)

{

echo "Failed to Connect to MySQL Database<br />";

echo mysql_error();

exit;

}

else{}

 

 

$con2 = mysql_select_db("nintendo_urlblurusers", $my);

 

if(!$con2)

{

echo mysql_error();

exit;

}

else

{

}

 

$con3 = mysql_query($var,$my);

if(!$con3)

{

echo mysql_error();

exit;

}

else

{

}

 

$con4 = mysql_query("INSERT INTO URLBlurUsers (Username,Password,Email,AccountType,PPEmail)

VALUES ('$username','$password','$email','$atype','$ppemail')");

 

if(!$con4)

{

echo mysql_error();

exit;

}

else

{

}

 

mysql_close($my);

echo '<div id="output"><br />You Have Registered Successfully<br /><br /></div>';

Link to comment
Share on other sites

$SafeVariable = addslashes(htmlspecialchars($RawVariable));

 

mysql_real_escape_string() is preferred over addslashes() now.

 

Also, generally HTML is escaped when outputting to the web browser, not when inserting.

 

 

 

 

pudge1, $var isn't defined anywhere.

Link to comment
Share on other sites

lol Guess there is a lot of problems with my script. I forgot to take out that thing after I removed something. Anyway thank you. But now I have another problem ughhhh Unknown Column PPEmail in Field List

 

Updated Code:

 

$my = mysql_connect("localhost","nintendo_pudge","Franz5211-");
if(!$my)
{
echo "Failed to Connect to MySQL Database<br />";
echo mysql_error();
exit;
}
else{}


$con2 = mysql_select_db("nintendo_urlblurusers", $my);

if(!$con2)
{
echo mysql_error();
exit;
}
else
{
}


$con4 = mysql_query("INSERT INTO URLBlurUsers (Username,Password,Email,AccountType,PPEmail)
VALUES ('$username','$password','$email','$atype','$ppemail')");

if(!$con4)
{
echo mysql_error();
exit;
}
else
{
}

mysql_close($my);
echo '<div id="output"><br />You Have Registered Successfully<br /><br /></div>';
?>

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.