Hello all,
I am having trouble writing to a database using php.
No errors are produced, but the data is not being writtern to the database.
here is the code:
$user = 'admin';
$db = 'forum';
$link = mysql_connect ("localhost", $user);
if (! $link)
die("</table><font color=red>Failed to open connection to SQL database</font>");
mysql_select_db($db)
or die ("</table><font color=red>Failed to open $db:" .mysql_error() ."</font>");
$query = "INSERT INTO forum (author, lastpost, replies, topic, post_date, message_body) values ('$_REQUEST[author]', now, 0, '$_REQUEST[topic]', now, '$_REQUEST[body]')";
mysql_query($query, $link)
or die ('<font color=red>Failed to write to database: '.mysql_error() .'</font>');
mysql_close($link);
I can't see anything wrong in there, anyone have any ideas?
Many thanks.
/Sib
programmer in the making
icq: 44167565
e-mail: siberdude@ntlworld.com
I am having trouble writing to a database using php.
No errors are produced, but the data is not being writtern to the database.
here is the code:
$user = 'admin';
$db = 'forum';
$link = mysql_connect ("localhost", $user);
if (! $link)
die("</table><font color=red>Failed to open connection to SQL database</font>");
mysql_select_db($db)
or die ("</table><font color=red>Failed to open $db:" .mysql_error() ."</font>");
$query = "INSERT INTO forum (author, lastpost, replies, topic, post_date, message_body) values ('$_REQUEST[author]', now, 0, '$_REQUEST[topic]', now, '$_REQUEST[body]')";
mysql_query($query, $link)
or die ('<font color=red>Failed to write to database: '.mysql_error() .'</font>');
mysql_close($link);
I can't see anything wrong in there, anyone have any ideas?
Many thanks.
/Sib
programmer in the making
icq: 44167565
e-mail: siberdude@ntlworld.com