gpt4 book ai didi

php - MySQL 语法错误

转载 作者:行者123 更新时间:2023-11-30 00:14:43 25 4
gpt4 key购买 nike

我已经使用在线工具测试了我的查询,但没有成功。我被困住了; http://www.piliapp.com/mysql-syntax-check/

这是我的代码;

SELECT Replace(Replace(Replace(Mid( 
Substring_index(
node_data_field_pdf_download.field_pdf_download_data,
':"',
3), 30), '";s:3', ''), ':', ''), '"', '') AS
language,
files.filepath
AS filepath
FROM node
LEFT JOIN content_field_pdf_download node_data_field_pdf_download
ON node.vid = node_data_field_pdf_download.vid
LEFT JOIN files files
ON files.fid = node_data_field_pdf_download.field_pdf_download_fid
WHERE ( node.status = 1 )
AND ( node.type IN ( 'codeofconduct' ) )

我尝试过使用转义字符,但结果仍然相同。我已经在 phpMyAdmin 2.11.7 上测试了上面的查询,它工作得很好。

当我尝试将它与 php 代码一起使用时,它呈现错误。完整代码如下;

<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post">
<select class="neutral" id="type" name="type" onchange="window.open(this.options[this.selectedIndex].value)"> <?php
$sql = "SELECT REPLACE(REPLACE(REPLACE(MID(SUBSTRING_INDEX(node_data_field_pdf_download.field_pdf_download_data, ':\"', 3),30),'";s:3',''),':',''),'\"','') AS language,
files.filepath AS filepath FROM node
LEFT JOIN content_field_pdf_download node_data_field_pdf_download ON node.vid = node_data_field_pdf_download.vid
LEFT JOIN files files ON files.fid = node_data_field_pdf_download.field_pdf_download_fid
WHERE (node.status = 1) AND (node.type in ('codeofconduct'))";

$result = db_query($sql);

echo '<option value="" disabled selected>-- Please select --</option>';

while($row = db_fetch_array($result)) {
$filepath[] = $new_array['filepath'];
echo '<option value="'.$row['filepath'].'">'.$row['language'].'</option>';

}

?>

最佳答案

问题是

(node_data_field_pdf_download.field_pdf_download_data, ':\"', 3),30),'";s:3',''),':','')
^ here

"之前使用\

试试这个

$sql = "SELECT REPLACE(REPLACE(REPLACE(MID(SUBSTRING_INDEX(node_data_field_pdf_download.field_pdf_download_data, ':\"', 3),30),'\"s:3',''),':',''),'\"','') AS language, 
files.filepath AS filepath FROM node
LEFT JOIN content_field_pdf_download node_data_field_pdf_download ON node.vid = node_data_field_pdf_download.vid
LEFT JOIN files files ON files.fid = node_data_field_pdf_download.field_pdf_download_fid
WHERE (node.status = 1) AND (node.type in ('codeofconduct'))";

关于php - MySQL 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23754819/

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