Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

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

Engaged ,
Jan 16, 2013 Jan 16, 2013

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

TOPICS
Server side applications
4.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 16, 2013 Jan 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 16, 2013 Jan 16, 2013

i see that but wasnt surem, do you mean

$row_detailsRS[$details_prodID] . "";

change to

$row_detailsRS[$details_prodID] . " " ;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 16, 2013 Jan 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 17, 2013 Jan 17, 2013

that didnt work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 18, 2013 Jan 18, 2013
LATEST

Bummer. Your code has 3 recordsets - you'll need to comment them out (and their associated code) one at a time until you find the offending recordset.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines