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?

Link to comment
Share on other sites

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'

Link to comment
Share on other sites

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')";

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.