This topic is locked

want to get Des and Size to edit page select modelno in the add page

6/26/2008 2:31:30 PM
PHPRunner General questions
C
coolumanga author

i got this 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 '(Description, Size) WHERE (Array)' at line 1
i want to get description and size to the edit page when selecting model no in sc_item from model table
global $conn;

$strSQLExists = "select * from Model where Model_No='".$values["Model_No"]."'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data)

{

// if record exists do something

// echo $values["Sc_No"]." Is found";
$strSQLExists = "select MAX(LineNo)AS Max_Line_No from SC_Item where LineNo='".$values["LineNo"]."'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);
global $conn;

$strSQLUPdate = "UPDATE SC_Item SET (Description, Size) WHERE ($data)";

db_exec($strSQLUPdate ,$conn);
}

else

{

// if dont exist do something else
}

A
alang 6/26/2008

Check syntax on SQL update:
UPDATE table

SET column = expression

WHERE predicates;

J
Jane 6/27/2008

Hi,
to debug your code print all queries before execution.

$strSQLExists="...";

echo $strSQLExists;


Regarding your code.

Here is the correct query:

$strSQLUPdate = "UPDATE SC_Item SET (Description, Size) WHERE ('".$data["FieldName1"]."','".$data["FieldName2"]."')";



where FieldName1 and FieldName2 are your actual field names.