MySQL - Can't save data on a table

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply

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
php-forum Active User
php-forum Active User
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire

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());

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

Tue Dec 25, 2012 8:44 pm


Try below code

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

Post Reply