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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.