Jump to content

MySQL database not updating from php code


tjverge

Recommended Posts

the below code as I understand should insert a new record into my database, but it's not.

 

<?php
$notes = $_POST['notes'];
$cnamedb = $_POST['cname'];
$username = $_SESSION['username'];

mysql_query("INSERT INTO `ccccomma_eve`.`corps` (`id`, `name`, `ticker`, `alliance`, `ceo`, `tax`, `members`, `hq`, `apidate`, `notes`, `notedate`, `updatedby`) VALUES ('', '$cnamedb', '', '', '', '', '', '', '', '$notes', NOW(), '$username'");

echo $cnamedb." Updated";
?>

 

Any ideas why?

updated to this so I could see the error:

<?php
$notes = $_POST['notes'];
$cnamedb = $_POST['cname'];
$username = $_SESSION['username'];

$query ="INSERT INTO `ccccomma_eve`.`corps` (`id`, `name`, `ticker`, `alliance`, `ceo`, `tax`, `members`, `hq`, `apidate`, `notes`, `notedate`, `updatedby`) VALUES ('', '$cnamedb', '', '', '', '', '', '', '', '$notes', NOW(), '$username'";

mysql_query($query) or die('mysql error ' . mysql_error() . ' in query : ' . $query);

echo $cnamedb." Updated";
?>

this is the out put:

 

mysql error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 in query : INSERT INTO `ccccomma_eve`.`corps` (`id`, `name`, `ticker`, `alliance`, `ceo`, `tax`, `members`, `hq`, `apidate`, `notes`, `notedate`, `updatedby`) VALUES ('', 'The Choireporation', '', '', '', '', '', '', '', 'test', NOW(), 'TX1'

Sorry I don't see it they all look like they have a matching open and close... could you please post the right code?

 

Thank you

 

Still didn't work here is what I have:

 

$query ="INSERT INTO Corps (`id`, `name`, `ticker`, `alliance`, `ceo`, `tax`, `members`, `hq`, `apidate`, `notes`, `notedate`, `updatedby`) VALUES ('', '$cnamedb', '', '', '', '', '', '', '', '$notes', NOW(), '$username')";

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.