我想從用戶輸入然後從表中提取數據並顯示它。
我的代碼是
$ini = $_GET["ini_id"];
$con=mysqli_connect("localhost","root","","globalgoals");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
else
{
$country = array();
//country
$sql="";
//!mysqli_query($con,$sql))
$result = mysqli_query($con,"SELECT * FROM country WHERE metrics="$ini");/*table name*/
while($row = mysqli_fetch_array($result))
{
array_push($country,$row['country']);/*column name*/
}
//
當我輸入網址http://localhost/xampp/testing/Int/table.php?ini=C2C
我得到的錯誤
Notice: Undefined index: ini_id in C:\xampp\htdocs\xampp\Testing\Int\table.php on line 2
,因爲它是在'$ _GET [「ini」];',仔細看鏈接。 **並且您很容易受到sql注入攻擊** – 2013-03-22 08:51:39
您應該仔細研究PDO或MySQLI。 Mysql_函數已被棄用,並且您的代碼很容易被注入! – Elias 2013-03-22 08:55:12
它不會是活的,它只是爲Exec的 – 2013-03-22 08:57:46