Jump to content

[SOLVED] mysql_query insert issue


williamZanelli

Recommended Posts

Hi guys,

 

I have an issue with "mysql_query" insert statments.

 

I can extract data from my DB ie if I had a select query it works fine.

 

Here the code for my "insert" query.. can anyone see what the prob may be?

 

 

error_reporting(E_ALL);
ini_set("display_errors", 1); 

$id = 773;
$message = 'HAHahahahha';
$time = time();

$sql = "INSERT INTO messages (user, message, date_, up, down) VALUES($id, $message, null, 0, 0)";


$dbhost ='111.111.111.111';
$dbuser = 'dbuser';
$dbpass = 'mypass';
$dbname = 'dbname';

$con = mysql_connect($dbhost,$dbuser,$dbpass);
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("webyolkco3", $con);

$x = mysql_query($sql) or die("Couldn't execute query2. ");


mysql_close($con);



 

This always seems to be throwing a "Couldn't execute query2." message, any ideas?

 

Thanks for your advice in advance

 

Will

 

 

Link to comment
https://forums.phpfreaks.com/topic/160817-solved-mysql_query-insert-issue/
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.