MySQL - Can't save data on a table

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
jp26198926

Re: MySQL - Can't save data on a table

Post by jp26198926 » Thu Dec 20, 2012 6:35 pm

$sql = "INSERT INTO coll(banda, disco, ano) VALUES ($banda, $disco, $ano)";
cant find these fields (i.e banda,disco, ano) in your sql script.
also these variables (i.e $banda, $disco, $ano)

User avatar
simplypixie
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire
Contact:

Re: MySQL - Can't save data on a table

Post by simplypixie » Sat Dec 22, 2012 12:38 am

Tray adding a space between your table name and the column names, add quote marks around your variables (plus your variables don't match the variable names above) and add mysql_error to the end to display any errors that may be happening:

Code: Select all

$sql = "INSERT INTO coll (banda, disco, ano) VALUES ('$band', '$album', '$year')" or die(mysql_error());

sudheer
New php-forum User
New php-forum User
Posts: 28
Joined: Wed Dec 21, 2011 1:41 am

Re: MySQL - Can't save data on a table

Post by sudheer » Tue Dec 25, 2012 8:44 pm

Hi,

Try below code

$sql = mysql_query("INSERT INTO coll (banda, disco, ano) VALUES ('".$_REQUEST['band']."','".$_REQUEST['album']."','".$_REQUEST['year']."')");

Post Reply

Who is online

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