Fluffy2000
06-13-2004, 09:53 PM
I'm having trouble connecting to my MySQL database. I don't know what's wrong.
|
View Full Version : MySQL Help Fluffy2000 06-13-2004, 09:53 PM I'm having trouble connecting to my MySQL database. I don't know what's wrong. Cherchezlafemme 06-13-2004, 10:10 PM Ok can we see the code you are using? Fluffy2000 06-13-2004, 10:25 PM <?php // database information $dbhost="localhost"; $dbuser="noah0504_xmb1"; $dbpass="791305"; $dbname="noah0504_users"; // disconnected timeout $timeout = 60; // in seconds.. you can make it higher or lower.. i suggest keeping it at 1 minute // this will tell apart the people on your site $ip=getenv("REMOTE_ADDR"); //connect to database mysql_connect($dbhost,$dbuser,$dbpass); // remove old connections so that the number doesn't continue to rise like a counter $strq = "DELETE FROM joined WHERE hl < now()"; $qry = mysql_db_query($dbname,$strq); $strq = "SELECT count(*) FROM joined WHERE IP='$ip'"; $qry = mysql_db_query($$dbname,$strq); while ( $r = @mysql_fetch_array($qry) ) { $ppl = $r["count(*)"]; } if ($cpt) { // checks for reloads, etc.. $strq = "UPDATE joined SET hl=hl + $timeout WHERE ip='$ip'"; } else { // confirmed user updated into database $strq = "INSERT INTO joined (ip, hl) VALUES ('$ip', now()+ $timeout)"; } $qry = mysql_db_query($dbname,$strq); // display the number of connected people $strq = "SELECT count(*) FROM joined"; $qry = mysql_db_query($dbname, $strq); while ( $result = @mysql_fetch_array($qry) ) { $ppl = $result["count(*)"]; } ?> pb&j 06-14-2004, 04:25 AM is this your error or because this forum puts a space in some words... mysql_connect($dbhost,$db user,$dbpass); $dbuser can you tell us any error that appears during your "non-connection"? Fluffy2000 06-14-2004, 04:49 AM Not sure. I'll look at it. Fluffy2000 06-15-2004, 02:51 AM It's the forum. pb&j 06-15-2004, 05:52 AM try changing this... //connect to database mysql_connect($dbhost,$dbuser,$dbpass); to this... // connect to the mysql database server. $link_id = mysql_connect ($dbhost, $dbuser, $dbpass); // select the specific database name we want to access. if (!mysql_select_db($dbname)) die(sql_error()); note : there is no space after $dbname in the last line. Fluffy2000 06-15-2004, 06:01 AM I got it to work, thanks. |