2010-12-04, 06:03 PM
Didn't know where else to put this, so yeah...
I'm trying to fetch info from DataBase. What this script is suppose to do is basically
1) get the User's IP address.
2) fetch "lastip" from mybb_users
3) match up user's IP with "lastip"
4) return user info (username, post count, etc)
I'm getting: "No database selected" from my script.
I'm trying to fetch info from DataBase. What this script is suppose to do is basically
1) get the User's IP address.
2) fetch "lastip" from mybb_users
3) match up user's IP with "lastip"
4) return user info (username, post count, etc)
I'm getting: "No database selected" from my script.
<?php
//Get the IP of the user.
$ip = $_SERVER['REMOTE_ADDR'];
//Database info
$user = "mysql username";
$pass = "password";
$db = "mysqldb";
$host = "host";
//Connect to DB
$cid = mysql_connect($host,$user,$pass);
if (!$cid) {echo("ERROR: " . mysql_error() . "\n");}
//Fetch info
$query = "SELECT * FROM mybb_users";
$result = mysql_query($query);
//I get "No database selected" right here, on "die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
echo $row['lastip'];
?>