Skip to main content
Inspiring
January 16, 2013
Question

error in your SQL syntax........near '' at line 1

  • January 16, 2013
  • 1 reply
  • 4588 views

i have a payment success page that should update the database when a payment is correct but am getting the 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

on the success.php page, i have looked at the code but cant seem to see the error, i have changed the ' ' to "" on line one but that didn't do it so was hoping someone could look and see the incorrect syntax

<?php require_once('Connections/chic.php'); ?>

<?php

// *** Update the stock ***

$details_table = "chicJewls_orderdetails";

$ID_column = "UniqueID";

$details_prodID = "ProductID";

$details_qty = "Quantity";

$XStock_TableName = "chicJewls_products";

$XStock_FieldName = "Stock";

$XStock_unID = "ProductID";

if (!session_id()) session_start();

if (isset($_SESSION["orderID"])) {

  mysql_select_db($database_chic, $chic);

  $details_Source = "select * from " .  $details_table . " where " . $ID_column . " = " . $_SESSION["orderID"];

  $detailsRS = mysql_query($details_Source, $chic) or die(mysql_error());

  $row_detailsRS = mysql_fetch_assoc($detailsRS);

  do {

    $XStock_qtySource = "select " . $XStock_FieldName . " from " .  $XStock_TableName . " where " . $XStock_unID . " = " .$row_detailsRS[$details_prodID] . "";

    $XStock_rsUpd = mysql_query($XStock_qtySource, $chic) or die(mysql_error());

    $row_XStock_rsUpd = mysql_fetch_assoc($XStock_rsUpd);

    if ($row_XStock_rsUpd[$XStock_FieldName] > 0) {

      $XStock_new = $row_XStock_rsUpd[$XStock_FieldName] - $row_detailsRS[$details_qty];

      if ($XStock_new < 0) $XStock_new = 0;

      $XStock_UpdSource = "update " . $XStock_TableName . " set " . $XStock_FieldName . " = " . $XStock_new . " where " . $XStock_unID . " = " .$row_detailsRS[$details_prodID] . "";

      $XStock_rsUpd = mysql_query($XStock_UpdSource, $chic) or die(mysql_error());

    }

  } while ($row_detailsRS = mysql_fetch_assoc($detailsRS));

  $XStock_rsUpd = null;

  $detailsRS = null;

  session_unregister("orderID");

}

?>

thanks in advance

This topic has been closed for replies.

1 reply

Participating Frequently
January 16, 2013

>.$row_detailsRS[$details_prodID] . ""

I'n not sure but I think the dot operator needs a space before and after. You are missing the space after the dot in two locations in this script.

Inspiring
January 16, 2013

i see that but wasnt surem, do you mean

$row_detailsRS[$details_prodID] . "";

change to

$row_detailsRS[$details_prodID] . " " ;

Participating Frequently
January 16, 2013

No, I'm talking about the dot before.

Change this

.$row_detailsRS[$details_prodID] . "";

to this

. $row_detailsRS[$details_prodID] . "";

in both places.