Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Getting mysql_error 0

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Getting mysql_error 0

Postby Gigga » Fri Oct 12, 2012 7:25 pm

Why do I fall into the "Problem" echo and mysql_error is 0. I am going crazy. It was working before and I dont know what I did. :?
Thanks!

======================
$cryptps = crypt($_POST['password']);
$sql=("INSERT INTO members (username, first_name, last_name, email_addr, location, carpool, join_date, profession, marital_status, send_event, send_comment,

password)
VALUES ('$_POST[username]', '$_POST[first_name]', '$_POST[last_name]','$_POST[email_addr]','$_POST[location]', '$_POST[carpool]', curdate(), '$_POST

[profession]', '$_POST[status]', '$_POST[emailevt]','$_POST[emailcmt]','$cryptps')");
$result = mysql_query($sql,$con);
if(!$result)
{
if (mysql_errno() == 1062)
{
echo '<br></br>';
echo "Username already exists. Please go back and try again.";
}
else
{
mysql_close($con);
echo '<br></br>';
echo "Problem* " ;
die('Error: ' . mysql_error() );
}
}
else
{

echo '<br></br>';
echo "Congratulations! You are registered."
Gigga
New php-forum User
New php-forum User
 
Posts: 5
Joined: Tue Oct 09, 2012 6:43 pm

Re: Getting mysql_error 0

Postby macek » Fri Oct 12, 2012 11:25 pm

Could you send us: echo 'XXX ' . $sql . ' XXX'; ?
User avatar
macek
php-forum Active User
php-forum Active User
 
Posts: 277
Joined: Wed Aug 25, 2010 10:42 am

Re: Getting mysql_error 0

Postby Gigga » Sat Oct 13, 2012 7:14 am

Here it is:

xxx INSERT INTO members (username, first_name, last_name, email_addr, location, carpool, join_date, profession, marital_status, send_event, send_comment, password) VALUES ('Lucy', 'Lucy', 'Wong','lucywong@gmail.com','United States', 'n', curdate(), 'Programmer', 'single', 'y','y','$1$Dj0.QZ4.$N6/ivKCDrxyFdV4NlCE.00') xxx

Thanks!
Gigga
New php-forum User
New php-forum User
 
Posts: 5
Joined: Tue Oct 09, 2012 6:43 pm

Re: Getting mysql_error 0

Postby Gigga » Sat Oct 13, 2012 2:19 pm

Never mind. I figured it out. It was my $con!
Gigga
New php-forum User
New php-forum User
 
Posts: 5
Joined: Tue Oct 09, 2012 6:43 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.