0

I'm trying to create an array to use for a curl_multi_exec, but I can't seem to create the array properly.

Here is my code:

$SQL = mysql_query("SELECT url FROM urls") 
       or die(mysql_error()); //Query the shell table
while($resultSet = mysql_fetch_array($SQL)) {
  $urls[] = $resultSet;
}    
echo $urls; //Test that the array works

But when I run this script, all it does is echo "Array"

I have no idea what I'm doing wrong, I've checked around google a bit, but can't figure it out. Any insight would be appreciated.

Johan
  • 74,508
  • 24
  • 191
  • 319
Rob
  • 7,980
  • 30
  • 75
  • 115
  • dnagirl caught it, Col. Shrapnel. I expected it to print out the rows from the MySQL. – Rob Apr 26 '10 at 17:14
  • i know you wanted rows. what format it should be? And how PHP would know this format? – Your Common Sense Apr 26 '10 at 17:15
  • Well mostly, at the moment I just wanted it to print the full array so I can make sure the array is set correctly, but if you're looking for my ultimate goal, you can find it here: http://stackoverflow.com/questions/2713876/how-can-i-send-get-data-to-multiple-urls-at-the-same-time-using-curl – Rob Apr 26 '10 at 17:17
  • i have just merely asked you of what text you wanted to be printed. an example. of text. but you fail to realize the simple fact that it is text being printed when we see anything in the browser. – Your Common Sense Apr 26 '10 at 17:25
  • I simply wanted it to print (in text) the contents of the requested rows, to verify that the array worked. – Rob Apr 26 '10 at 17:26
  • array is a complex structure, not a text (or "scalar") variable. PHP just unable to determine what text should be printed. and you failed to define it again. – Your Common Sense Apr 27 '10 at 08:51
  • Col. Shrapnel, I don't understand how you can't figure out what I'm trying to do. I just want to print the contents of the array. dnagirl has already answered the question and solved it, but you still can't understand what I'm trying to do? – Rob Apr 27 '10 at 17:00

2 Answers2

3

print_r($urls) or var_dump($urls)

echo assumes a scalar value.

dnagirl
  • 20,196
  • 13
  • 80
  • 123
  • Aha, that was easy. Much appreciated, I'll keep this in mind for future reference. Also, could link me to something that explains this more in detail? Or explain it yourself? (Also, can't accept answer for another 11 minutes. Bah) – Rob Apr 26 '10 at 17:13
  • @Rob: best place for PHP info is the manual (no sarcasm, honest!) http://ca.php.net/manual/en/index.php Have a look here for echo http://ca.php.net/manual/en/function.echo.php, print_r http://ca.php.net/manual/en/function.print-r.php and var_dump http://ca.php.net/manual/en/function.var-dump.php – dnagirl Apr 26 '10 at 17:22
0

You can use the print_r() function.

print_r($urls)
Sarfraz
  • 377,238
  • 77
  • 533
  • 578