rbarnett Posted October 8, 2008 Share Posted October 8, 2008 I'm trying to grab some data off of a list of webpages and display it to the page. The list of urls are from a mysql table and I then use the curl function to grab the data. The only problem is that I only get the first row. Can anyone please tell me what I am doing wrong. When I echo $row['website'] without the curl section I get my full listing. Here is the code: $query = "select accountname, website from vtiger_account where website <> ''"; $result = mysql_query($query); echo '<table border="1"> <th>iPass Site</th><th>Version</th>'; while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $url = $row['website']; echo '<tr><td>'.$url.'</td>'; //echo $url . '<br />'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec ($ch); curl_close ($ch); $length=strpos($data,"Version: "); $result=substr($data,$length +9,32); if (preg_match("/Version:/", $data)) { echo '<td>'.$result . '</td></tr>'; } else { echo '<td>No version found</td></tr>'; } } echo '</table>'; Link to comment https://forums.phpfreaks.com/topic/127587-looping-with-curl/ Share on other sites More sharing options...
ratcateme Posted October 8, 2008 Share Posted October 8, 2008 looking at the code i can't see anything that could cause that try adding this somewhere echo error_reporting(E_ALL); ini_set("display_errors", true); to see if your code is getting an error that is stopping the loop. Scott. Link to comment https://forums.phpfreaks.com/topic/127587-looping-with-curl/#findComment-660184 Share on other sites More sharing options...
rbarnett Posted October 8, 2008 Author Share Posted October 8, 2008 Thanks for the response. Inserting the error code displays 6143. Do you know what this means? I looked it up but I can't find anything intelligible to me. Link to comment https://forums.phpfreaks.com/topic/127587-looping-with-curl/#findComment-660187 Share on other sites More sharing options...
ratcateme Posted October 8, 2008 Share Posted October 8, 2008 sorry your not meant to echo it. the number is the value of the old error reporting value. but you get no new errors? try adding this above the loop echo mysql_num_rows($result); should tell you how many results you are getting back Scott. Link to comment https://forums.phpfreaks.com/topic/127587-looping-with-curl/#findComment-660189 Share on other sites More sharing options...
rbarnett Posted October 8, 2008 Author Share Posted October 8, 2008 I'm getting 86 rows. -Rob Link to comment https://forums.phpfreaks.com/topic/127587-looping-with-curl/#findComment-660196 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.