problem with php and mysql -
i trying connect db not on same server script.
it doesn't work, why?
mysql_connect('twstg.com', 'myuser', 'mypass'); $data = mysql_query("select * websites order rand() limit 1"); while($info = mysql_fetch_array( $data)) { $url = $info['url']; echo $url; }
(this big comment, update answer appropriate when more data provided)
what's error you're getting, can't expect magically know that. there many things go wrong, whether it's in connection, query, or loop (if there no results).
you can check error doing this:
mysql_connect(..) or die(mysql_error()); $data = mysql_query(); die(mysql_error());
if there no errors that, you're still missing call mysql_select_db()
. wouldn't required if, example, doing select * database.websites
, you're not :)
Comments
Post a Comment