mySQL INSERT playing up...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tommy1987
Forum Commoner
Posts: 92
Joined: Tue Feb 21, 2006 8:35 pm

mySQL INSERT playing up...

Post by tommy1987 »

Can anyone spot what is wrong here, tried for too long.... :(

Im trying to insert the variables: $fromconf, $contentconf and the text value "Unread". Its not inserting at all, however, I have an if($result) { echo 'Success!'; } and its displaying the success message which is confusing.

e.g. of what $table equals:

$table = "PM_Tom";

Code: Select all

$query = "INSERT INTO $table (Date, From, Content, ReadUnread) VALUES (now(), '$fromconf', '$contentconf', 'Unread')";
$result = mysql_query($query);
Hope someone can help,, Thanks, Tom
NiGHTFiRE
Forum Contributor
Posts: 156
Joined: Sun May 14, 2006 10:36 am
Location: Sweden

Post by NiGHTFiRE »

Code: Select all

$query = "INSERT INTO $table (Date, From, Content, ReadUnread) VALUES (now(), '$fromconf', '$contentconf', 'Unread')"; 
$result = mysql_query($query) or die(mysql_error());
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

Code: Select all

$query = "INSERT INTO ".$table." (`Date`, `From`, `Content`, `ReadUnread`) VALUES ('".now()."', '".$fromconf."', '".$contentconf."', 'Unread')";
$result = mysql_query($query) or die(mysql_error());
Post Reply