Geodesic_D
02-11-2010, 07:22 PM
I'm trying to write a PHP script that selects two random words from a database. It's just for a little fun thing I have in mind.
The code I am using is such:
<?php
mysql_connect("IP:PORT", "USERNAME", "PASSWORD") or die("Unable to connect to database.");
mysql_select_db("DBNAME") or die("Unable to select database");
$result1=mysql_query("SELECT word1 FROM guildname ORDER BY RAND() LIMIT 1");
$result2=mysql_query("SELECT word2 FROM guildname ORDER BY RAND() LIMIT 1");
echo($result1 . " Stole My " . $result2);
mysql_close();
?>
The only words I have in the database at the moment are "One" to "Ten". When I run the script, instead of something like:
Three Stole My Two
I get this:
Resource id #3 Stole My Resource id #4
I have no idea what is going wrong here, and I was hoping someone could provide the answer. I got the code snippets from a tutorial, and I followed said tutorial to the leter!
The code I am using is such:
<?php
mysql_connect("IP:PORT", "USERNAME", "PASSWORD") or die("Unable to connect to database.");
mysql_select_db("DBNAME") or die("Unable to select database");
$result1=mysql_query("SELECT word1 FROM guildname ORDER BY RAND() LIMIT 1");
$result2=mysql_query("SELECT word2 FROM guildname ORDER BY RAND() LIMIT 1");
echo($result1 . " Stole My " . $result2);
mysql_close();
?>
The only words I have in the database at the moment are "One" to "Ten". When I run the script, instead of something like:
Three Stole My Two
I get this:
Resource id #3 Stole My Resource id #4
I have no idea what is going wrong here, and I was hoping someone could provide the answer. I got the code snippets from a tutorial, and I followed said tutorial to the leter!