php - Error in MySQL Syntax using select statement -
hi can please me in this, don't know error is. here code:
$capacitance =@mysql_query ("select distinct wwpn, substr(val, 1, length(val) / 2) capacitor, substr(val, length(val) / 2+1) capasitance bom_csv boardnumber ='$board' , qty<>'' , qty !='qty'"); @mysql_query($capacitance,$connect)or die("failed execute query:<br />" . mysql_error(). "<br />" . mysql_errno()); while($row = mysql_fetch_array($capacitance)) { $capacitor = $row['capacitor']; $capacitance =$row['capasitance']; $adi_pn = $row['wwpn']; }
and error while executing php:
failed execute query: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'resource id #4' @ line 1 1064
your first mysql_query
returning resource (a resultset) , assigning $capacitance
. when execute mysql_query
again in next line, $capacitance
, resource, turned string - "resource #4"
, - not proper sql.
also note "bobby tables doesn't go school" not true: escape strings properly.
$capacitance = @mysql_query ("select distinct wwpn, substr(val, 1, length(val) / 2) capacitor, substr(val, length(val) / 2+1) capasitance bom_csv boardnumber ='" . mysql_real_escape_string($board) . "' , qty<>'' , qty !='qty'", $connect) or die("failed execute query:<br />" . mysql_error(). "<br />" . mysql_errno()); while ...
Comments
Post a Comment