未知列在Where子句mysql查询中

时间:2012-07-13 21:15:45

标签: php mysql

我的查询是$query = "SELECT * FROM cartmatch WHERE CARTNO=$cart4";,我收到的错误是“where子句”中的“未知列'M833'”。你知道吗,cart4 = M833。

:: EDIT :: 出于某种原因,没有任何表现。这是页面上的代码。

<?php
$cart1 = rawurldecode($_GET["path"]);
list( , , , , , $cart2) = explode ("\\", $cart1);
$cart3 = $cart2;
list($cart4) = explode (" ", $cart3);

$con = mysql_connect("SERVER","USERNAME","PASSWORD");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("cartmatch", $con);

$result = mysql_query("SELECT * FROM cartmatch WHERE CARTNO='$cart4'");

while($row = mysql_fetch_array($result))
  {
echo '<form enctype="multipart/form-data" action="album.php" method="POST">Please enter press save.<br><br><input name="ID" type="hidden" value=';
echo $_GET["ID"];
echo ' ><input name="enabled" type="hidden" value=';
echo $_GET["enabled"];
echo ' ><input name="artist" type="hidden" value=';
echo $_GET["artist"];
echo ' ><input name="title" type="hidden" value="';
echo $_GET["title"];
echo '" >Name:<br/><input name="album" type="text" autofocus="autofocus" value="';
echo $row['ALBUM'];
echo '" ><input type="submit" name="edit" value="Save"></form>';
  }

mysql_close($con);
?>

2 个答案:

答案 0 :(得分:1)

将查询更改为:

"SELECT * FROM cartmatch WHERE CARTNO='$cart4'"

并更改

list($cart4) = explode (" ", $cart3); 

list($cart4) = explode ("+", $cart3);

答案 1 :(得分:1)

将WHERE部分更改为

CARTNO='$cart4'