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.

7
  • dnagirl caught it, Col. Shrapnel. I expected it to print out the rows from the MySQL. Commented Apr 26, 2010 at 17:14
  • i know you wanted rows. what format it should be? And how PHP would know this format? Commented Apr 26, 2010 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: stackoverflow.com/questions/2713876/… Commented Apr 26, 2010 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. Commented Apr 26, 2010 at 17:25
  • I simply wanted it to print (in text) the contents of the requested rows, to verify that the array worked. Commented Apr 26, 2010 at 17:26

2 Answers 2

3

print_r($urls) or var_dump($urls)

echo assumes a scalar value.

Sign up to request clarification or add additional context in comments.

2 Comments

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: best place for PHP info is the manual (no sarcasm, honest!) ca.php.net/manual/en/index.php Have a look here for echo ca.php.net/manual/en/function.echo.php, print_r ca.php.net/manual/en/function.print-r.php and var_dump ca.php.net/manual/en/function.var-dump.php
0

You can use the print_r() function.

print_r($urls)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.