Jump to content

[SOLVED] MySQL insert problem


gs

Recommended Posts

Hi, I really need some help with this, Ive been trying to figure it out for such a long time!

 

Ok, I want this to connect to the database, and then insert info into the table, which I already have created. Here is the exact script:

 

<?php

 

$username = $_COOKIE['ID_my_site'];

$msg = $_POST['message'];

$to = $_POST['to'];

 

 

mysql_connect("freshsql.com","username","password")or die("SQL Error".mysql_error());;

mysql_select_db("data1")or die("SQL Error".mysql_error());;

 

$query="INSERT INTO messages(username,from,message) VALUES('$to',$username','$msg')";

mysql_query($query)or die("SQL Error".mysql_error());

 

 

?>

 

It keeps returning an error:

 

"SQL ErrorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''messages'(username,from,message) VALUES('gs',gs','gsaafd')' at line 1"

 

Please help! I cannot figure this out, Thanks

-GS

 

 

EDIT:

Use meaningful topic subject names and post in the correct forum.

 

Link to comment
https://forums.phpfreaks.com/topic/120030-solved-mysql-insert-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.