gpt4 book ai didi

php - 使用 GET 语句插入语句不起作用

转载 作者:行者123 更新时间:2023-12-01 00:45:35 25 4
gpt4 key购买 nike

我认为我的代码是错误的,因为所选字段根本没有插入到表/字段中。

我如何获得以下内容以使用 URL 中的以下引用。

 $sql="INSERT INTO Instruction (PhysioReference, Physio, PhysiosAddress, postcode, Physiomobile, Number, Physiofax, PhysiosEmail WHERE Reference='$Reference') 
SELECT PhysioReference, Name, Line1, Postcode, Mobile, Tel, Fax, Email from `Physio` WHERE PhysioReference='$PhysioReference'";

示例 URL: http://test.com/Physiotoinstruction.php?PhysioReference=100099&a ‌ mp;Reference=456789

页面.php

<?php

require_once('auth.php');

$host=""; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name=""; // Database name
$tbl_name="Instruction"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");



$Reference=mysql_real_escape_string($_GET['Reference']);
$PhysioReference=mysql_real_escape_string($_GET['PhysioReference']);

$sql="INSERT INTO Instruction (PhysioReference, Physio, PhysiosAddress, postcode, Physiomobile, Number, Physiofax, PhysiosEmail WHERE Reference='$Reference')
SELECT PhysioReference, Name, Line1, Postcode, Mobile, Tel, Fax, Email from `Physio` WHERE PhysioReference='$PhysioReference'";

$result=mysql_query($sql);



//$sql="INSERT INTO Triage (Reference, Forename)
//SELECT Reference, Forename FROM `Instruction`
//WHERE Reference='$Reference' LIMIT 1";

echo "Successful";
echo "<BR>";
echo "<a href='insert.php'>View result</a>";
// mysql_error()



?>

最佳答案

MySQL INSERT Syntax不支持 WHERE 子句,因此您的查询将失败。

尝试将 PhysiosEmail WHERE Reference='$Reference') 替换为 PhysiosEmail)

关于php - 使用 GET 语句插入语句不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22634839/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com