Forum Moderators: coopster
<?php
// REPLACE FIELDS
mysql_connect("localhost", "#*$!x", "#*$!x") or die(mysql_error());
mysql_select_db("#*$!x") or die(mysql_error());
$query="SELECT * FROM #*$!x";
$result=mysql_query($query);
$num=mysql_numrows($result);
$i=0;
while ($i < $num) {
$dirname=mysql_result($result,$i,"dirname");
$ch = curl_init ("http://example.com/Models/$dirname/1.jpg");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
$rawdata=curl_exec ($ch);
curl_close ($ch);
mkdir($dirname, 0777);
$fp = fopen("$dirname/1.jpg",'w');
fwrite($fp, $rawdata);
fclose($fp);
?>
please advise!
[edited by: eelixduppy at 11:33 pm (utc) on Dec. 29, 2008]
[edit reason] please use example.com, thanks [/edit]
while ($i < $num) { The second problem is, you don't increment the $i anywhere, so if $num is > 0 $i will always be less than $num, and your while loop will continue forever.