![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
相关问题
原代码如下:
| ID | " . "\n\tName | " . "\n\t|
|---|---|---|
| " . $row["id"] . " | " . "\n\t" . $row["name"] . " | " . "\n\t" . $row["email"] . " | " . "\n
"; } // end of function $scriptName = "example.php"; // Has the user provided the parameter? if (empty($regionName)) { // No, the user hasn't provided a parameter ?>
Home <?php } // end of if empty($regionName) body else { // Secure the user parameter $regionName $regionName = clean($regionName, 30); // Connect to the MySQL DBMS if (!($connection = @ mysql_connect($hostName, $username, $password))) die("Could not connect"); if (!mysql_select_db($databaseName, $connection)) showerror(); // Start a query ... //$query = "SELECT * FROM test t"; $query="select test.id, test.name, test.email from test " ; // ... then, if the user has specified a region, // add the regionName as an AND clause ... if ($regionName!="all") $query .= " AND test.name = \"$regionName\""; // ... and then complete the query. $query .= " ORDER BY test.name"; // run the query and show the results displayWinesList($connection, $query, $regionName); // Close the DBMS connection mysql_close($connection); } // end of else if empty($regionName) body ?> 当在text框中输入all时,查询可以显示数据,当输入想要查询的姓名时就会出现类似以下错误: Error 1064 : 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 'AND test.name = "roc" ORDER BY test.name' at line 4 高手帮忙看一下,怎么解决?
提问者:hepeng 08-17 17:05
答复
©2007 PhpRes.COM

