Jump to content

Recommended Posts

Ok guys im new to php mysql and i'm trying to insert some form information in my database. Im using a script from sitepoint in which i went through the tutorial did some experiments of my own and it worked....

 

but now i'm getting this error which i cant figure out....

 

Error placing order: 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 'order SET product ='1', size='medium', color='', quantity = '1' at line 1

 

here is the page

http://vaughntucker.com/imagecon/hats.php

 

and this is the script

<?php 

//default page display

//connect to database

$dbcnx = @mysql_connect('p3nl41mysql7.secureserver.net', 'imagecon', 'Dub*boss_1');

if (!$dbcnx) {

echo '<p> Unable to connect to the '. 'database server at this time.</p>';

exit();

 

}

 

//select database

if (!@mysql_select_db('imagecon')) {

exit('<p>Unable to locate the ' .

    'database at this time.</p>');

}

 

//Mysql query add joke

if (isset($_POST['submit'])) {

  $product = 1;

  $size = $_POST['size'];

  $color = $_POST['color'];

  $quan = $_POST['quantity'];

    $sql = "INSERT INTO order SET

      product ='$product',

  size='$size',

  color='$color',

  quantity = '$quan',

      date = CURDATE()";

  }else{

  echo 'No data submited';

 

  }

  if (@mysql_query($sql)) {

    echo '<p>Your order has been submited.</p>';

  } else {

    echo '<p>Error placing order: ' .

        mysql_error() . '</p>';

  }

 

 

 

?>

 

thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/135664-help-php-mysql-insert-script/
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.