Jump to content

Recommended Posts

Hi,

 

I'm trying to browse a number of website which I receive from my MySQL database at the same time. I tried to use curl but couldn't figure out how to do this.

 

My script so far looks like the following:

<?php
/*==================================
Author : Lord Nightslave
in_aeternum@hotmail.com
Load a query result into two dimensional array.
You can later refer the result in an array form with
the original field name.
i.e print $myresultarray[$i]["My Table Field Name"]
====================================*/
?>
<?php
/* You can put this in other file and just include it */
function OpenDb($hostname,$uid,$pwd,$dbname){
$link = @mysql_pconnect($hostname,$uid,$pwd);
if($link && mysql_select_db($dbname)){
return($link);
}
else{
return(FALSE);
}
}
?>
<?php
function QueryIntoArray($query){
        settype($retval,"array");
        
$result= mysql_query($query);
        if(!$result){
print "Query Failed";
        }        
        for($i=0;$i<mysql_numrows($result);$i++){
                for($j=0;$j<mysql_num_fields($result);$j++){
                        $retval[$i][mysql_field_name($result,$j)] = mysql_result
($result,$i,mysql_field_name($result,$j));
                }//end inner loop
        }//end outer loop
return $retval;
}//end function
?>
<!--An Example How To Use The functions
To try it simple change the appropriate variable to your own database & tables
-->
<HTML>
<HEAD>
<TITLE>PHP Array Test</TITLE>
</HEAD>
<BODY BGCOLOR=WHITE>
<?php
OpenDb("localhost","user","pass","dbname") or die("Failed Opening Database");
settype($myresult,"array");

$query = "SELECT word FROM links";
$myresult = QueryIntoArray($query);
for($i=0;$i<count($myresult);$i++){
$delink = $myresult[$i]["word"];
echo $delink;
}
?>
</BODY>
</HTML>

 

I actually tried this after

echo $delink;

$url=$delink;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
$xml = curl_exec ($ch);

 

But didn't work out :/

curl_close ($ch);

Link to comment
https://forums.phpfreaks.com/topic/104574-solved-curl-in-an-array/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.