-2

所以......我有这个回声声明:

echo 
$results['results'][0]['url'].','
.$results['results'][1]['url'].','
.$results['results'][2]['url'].','
.$results['results'][3]['url'].','
.$results['results'][4]['url'].','
.$results['results'][5]['url'].','
.$results['results'][6]['url'].','
.$results['results'][7]['url'].','
.$results['results'][8]['url'].','
.$results['results'][9]['url'].','

.$results['results'][0]['title'].','
.$results['results'][1]['title'].','
.$results['results'][2]['title'].','
.$results['results'][3]['title'].','
.$results['results'][4]['title'].','
.$results['results'][5]['title'].','
.$results['results'][7]['title'].','
.$results['results'][8]['title'].','
.$results['results'][9]['title'].','

.$results['results'][0]['desc'].','
.$results['results'][1]['desc'].','
.$results['results'][2]['desc'].','
.$results['results'][3]['desc'].','
.$results['results'][4]['desc'].','
.$results['results'][5]['desc'].','
.$results['results'][6]['desc'].','
.$results['results'][7]['desc'].','
.$results['results'][8]['desc'].','
.$results['results'][9]['desc'];

这有效,并在我拥有的谷歌刮板中输出前 10 个 url、前 10 个标题和前 10 个描述(我向您展示这个以证明脚本有效)(有很多文件要显示,所以我不会在这里展示它们)。我想将数据输入到 mysql 数据库中。

这个回显,回显这样的值:对于某个关键字...</p>

    http://cars.mainetoday.com/,http://www.nowvauxhall.co.uk/,http://www.youtube.com/watch?v=nDvggf0ltVo,......

如您所见,它们都用逗号分隔,并准备输入到mysql数据库中。数据库的连接和选择由一个正在工作(或者我认为)的小脚本负责。(再一次,我不打算展示这些文件,因为它们都是连接的,它们大约有 5 或 6 个,而且它们很长),所以……这是我用来输入一行的输入代码桌子:

mysql_query(

"INSERT INTO  'seo'.'serp' (
`keyword` ,
`URL1` ,
`URL2` ,
`URL3` ,
`URL4` ,
`URL5` ,
`URL6` ,
`URL7` ,
`URL8` ,
`URL9` ,
`URL10` ,
`Title1` ,
`Title2` ,
`Title3` ,
`Title4` ,
`Title5` ,
`Title6` ,
`Title7` ,
`Title8` ,
`Title9` ,
`Title10` ,
`Description1` ,
`Description2` ,
`Description3` ,
`Description4` ,
`Description5` ,
`Description6` ,
`Description7` ,
`Description8` ,
`Description9` ,
`Description10`
)
VALUES (
'cars to sale',


".htmlentities($results['results'][0]['url']).",
".htmlentities($results['results'][1]['url']).",
".htmlentities($results['results'][2]['url']).",
".htmlentities($results['results'][3]['url']).",
".htmlentities($results['results'][4]['url']).",
".htmlentities($results['results'][5]['url']).",
".htmlentities($results['results'][6]['url']).",
".htmlentities($results['results'][7]['url']).",
".htmlentities($results['results'][8]['url']).",
".htmlentities($results['results'][9]['url']).",

".htmlentities($results['results'][0]['title']).",
".htmlentities($results['results'][1]['title']).",
".htmlentities($results['results'][2]['title']).",
".htmlentities($results['results'][3]['title']).",
".htmlentities($results['results'][4]['title']).",
".htmlentities($results['results'][5]['title']).",
".htmlentities($results['results'][6]['title']).",
".htmlentities($results['results'][7]['title']).",
".htmlentities($results['results'][8]['title']).",
".htmlentities($results['results'][9]['title']).",

".htmlentities($results['results'][0]['desc']).",
".htmlentities($results['results'][1]['desc']).",
".htmlentities($results['results'][2]['desc']).",
".htmlentities($results['results'][3]['desc']).",
".htmlentities($results['results'][4]['desc']).",
".htmlentities($results['results'][5]['desc']).",
".htmlentities($results['results'][6]['desc']).",
".htmlentities($results['results'][7]['desc']).",
".htmlentities($results['results'][8]['desc']).",
".htmlentities($results['results'][9]['desc']));

输入行似乎不喜欢表格……;)我也试过:

mysql_query(

"INSERT INTO  'seo'.'serp' (
`keyword` ,
`URL1` ,
`URL2` ,
`URL3` ,
`URL4` ,
`URL5` ,
`URL6` ,
`URL7` ,
`URL8` ,
`URL9` ,
`URL10` ,
`Title1` ,
`Title2` ,
`Title3` ,
`Title4` ,
`Title5` ,
`Title6` ,
`Title7` ,
`Title8` ,
`Title9` ,
`Title10` ,
`Description1` ,
`Description2` ,
`Description3` ,
`Description4` ,
`Description5` ,
`Description6` ,
`Description7` ,
`Description8` ,
`Description9` ,
`Description10`
)
VALUES (
'cars to sale',


".$results['results'][0]['url'].",
".$results['results'][1]['url'].",
".$results['results'][2]['url'].",
".$results['results'][3]['url'].",
".$results['results'][4]['url'].",
".$results['results'][5]['url'].",
".$results['results'][6]['url'].",
".$results['results'][7]['url'].",
".$results['results'][8]['url'].",
".$results['results'][9]['url'].",

".$results['results'][0]['title'].",
".$results['results'][1]['title'].",
".$results['results'][2]['title'].",
".$results['results'][3]['title'].",
".$results['results'][4]['title'].",
".$results['results'][5]['title'].",
".$results['results'][6]['title'].",
".$results['results'][7]['title'].",
".$results['results'][8]['title'].",
".$results['results'][9]['title'].",

".$results['results'][0]['desc'].",
".$results['results'][1]['desc'].",
".$results['results'][2]['desc'].",
".$results['results'][3]['desc'].",
".$results['results'][4]['desc'].",
".$results['results'][5]['desc'].",
".$results['results'][6]['desc'].",
".$results['results'][7]['desc'].",
".$results['results'][8]['desc'].",
".$results['results'][9]['desc']);

仍然没有结果……但没有错误!???如果回声有效,为什么我不能插入行???为什么它没有显示任何错误?我已经为此工作了大约 15 个小时!我敢肯定这很简单...

我还尝试了 foreach 循环,其中 2 个,每个变量子集一个。没有错误,但没有插入行。

任何人都可以帮忙吗?谢谢,米格尔

像这样?

mysql_query(

"INSERT INTO  'seo'.'serp' (
`keyword` ,
`URL1` ,
`URL2` ,
`URL3` ,
`URL4` ,
`URL5` ,
`URL6` ,
`URL7` ,
`URL8` ,
`URL9` ,
`URL10` ,
`Title1` ,
`Title2` ,
`Title3` ,
`Title4` ,
`Title5` ,
`Title6` ,
`Title7` ,
`Title8` ,
`Title9` ,
`Title10` ,
`Description1` ,
`Description2` ,
`Description3` ,
`Description4` ,
`Description5` ,
`Description6` ,
`Description7` ,
`Description8` ,
`Description9` ,
`Description10`
)
VALUES (
'cars to sale',



'".htmlentities($results['results'][0]['url'])."',
'".htmlentities($results['results'][1]['url'])."',
'".htmlentities($results['results'][2]['url'])."',
'".htmlentities($results['results'][3]['url'])."',
'".htmlentities($results['results'][4]['url'])."',
'".htmlentities($results['results'][5]['url'])."',
'".htmlentities($results['results'][6]['url'])."',
'".htmlentities($results['results'][7]['url'])."',
'".htmlentities($results['results'][8]['url'])."',
'".htmlentities($results['results'][9]['url'])."',

'".htmlentities($results['results'][0]['title'])."',
'".htmlentities($results['results'][1]['title'])."',
'".htmlentities($results['results'][2]['title'])."',
'".htmlentities($results['results'][3]['title'])."',
'".htmlentities($results['results'][4]['title'])."',
'".htmlentities($results['results'][5]['title'])."',
'".htmlentities($results['results'][6]['title'])."',
'".htmlentities($results['results'][7]['title'])."',
'".htmlentities($results['results'][8]['title'])."',
'".htmlentities($results['results'][9]['title'])."',

'".htmlentities($results['results'][0]['desc'])."',
'".htmlentities($results['results'][1]['desc'])."',
'".htmlentities($results['results'][2]['desc'])."',
'".htmlentities($results['results'][3]['desc'])."',
'".htmlentities($results['results'][4]['desc'])."',
'".htmlentities($results['results'][5]['desc'])."',
'".htmlentities($results['results'][6]['desc'])."',
'".htmlentities($results['results'][7]['desc'])."',
'".htmlentities($results['results'][8]['desc'])."',
'".htmlentities($results['results'][9]['desc'])."')")

不工作,没有错误...

还有连接文件:

<?php

$conn_error = 'Could not connect.';

$mysql_host = 'localhost';
$mysql_user = 'root';
$mysql_pass = '';

$mysql_db = 'seo';

if (!mysql_connect($mysql_host, $mysql_user, $mysql_pass)||!mysql_select_db($mysql_db)) {

die($conn_error);
}
echo 'connected';
?>

就像您在页面顶部的回声中看到的那样,它在最后给出“连接”......

还有其他建议吗?

4

1 回答 1

0

您必须'像这样包含文本数据

'".htmlentities($results['results'][0]['url'])."',
^                                               ^

其他人也一样

于 2013-04-19T07:46:51.307 回答