php - Insert array of variables into mysql database -
so… have echo statement:
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']; that works, , outputs first 10 url’s, first 10 titles, , first 10 descriptions in google scraper have (i’m showing prove script works) (there many files show, not show them here). input data mysql database.
this echo, echos values this: keyword…
http://cars.mainetoday.com/,http://www.nowvauxhall.co.uk/,http://www.youtube.com/watch?v=ndvggf0ltvo,......
like can see, separated commas, , ready input mysql database. connection , selection of data base taken care of small script working (or think). (once again, not going show files because connected , 5 or 6 of them , long), so… input code i’m using put row table:
mysql_query( "insert '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 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'])); the input row seems dislike table… ;) tried:
mysql_query( "insert '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 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']); and still no results… no errors! ??? if echo works why can’t insert row??? , why not show errors? i’ve been working on 15 hours! i’m sure it’s simple...
i've tried foreach loops, 2 of them, 1 each subset of variables. no error, no rows inserted.
can help? thanks, miguel
like this?
mysql_query( "insert '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 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'])."')") not working, no errors...
ther connect file:
<?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'; ?> like see @ echo @ top of page, gives "connected" @ end...
any other sugjestions?
you have enclose text data in ' this
'".htmlentities($results['results'][0]['url'])."', ^ ^ others well
Comments
Post a Comment