Upon connecting to myqsl database...tadaaa: Everything in my config.php is correct, yet this still occurs. I've looked around the net and haven't found the solution yet >_> I'll even show you my code. open_db.php: <?php $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); ?> close_db.php: <?php mysql_close($conn); ?> config.php: <?php $dbhost = 'mysql4.freehostia.com'; $dbuser = 'robste332'; $dbpass = 'lkv81'; $dbname = 'robste332_dtb'; ?> test_db.php: <html> <head> <title>Revelations of the Ancients</title> <meta name="Keywords,XRealms,X-Realms" content="game" /> <link rel="stylesheet" type="text/css" href="theme.css" /> </head> <body> <?php include 'config.php'; include 'open_db.php'; $query = "SELECT name, subject, message FROM contact"; $result = mysql_query($query); while(list($name,$subject,$message)= mysql_fetch_row($result)) { echo "Name :$name <br>" . "Subject : $subject <br>" . "Message : $row <br><br>"; } include 'close_db.php'; ?> </body> </html>
That advice may NOT be correct if they are using a seperate mysql server as many hosts now do that. Is this a cPanel server? If so the correct format for the database name and username is cpanelusername_databasename cpanelusername_username Post again with more info.
I've tried it without the pass, with the cpanel stuff (I am guessing I'm not using cpanel), I've checked the username, database name, password and host several times and they are all correct as far as I know. And... that isn't my real db pass =P By the way I'm using freehostia
Could i clarify one thing? Why is the error message and the parameters in that message not inline with your configuration file? Is that because you changed it for DP? Cheers
Yes that's right DooBDee. I found the problem...the dbuser is supposed to be the same as the dbname (with some help from tech support). But...now I have another problem. I get this message: I have a sutle idea of what it means, but I'm still too new to PHP to locate the problem.
Hi, Firstly, I would use this code: while ($row = mysql_fetch_assoc($result)) { echo $row['name']; echo $row['subject']; echo $row['message']; } PHP: If the problem persists then there is problem with your select statement (not right table etc...).
Uh, well, I know no more about sql than php...I'm researching though. And that code produces another error. I feel it's sql related. Edit: I know how to gather stuff via query, but I just want to draw info for only so many lines. I wouldn't need a query for that would I? Oh, wait, this is the PHP section isn't it...sorry.
The "not valid result" part means your resource is bad, i.e. the query returned 0 rows. Check your query to make sure it responded. mysql_query($sql) or die(mysql_error()); PHP:
Problem definately lies your SELECT. Are you selecting valid fields, tables etc...? Make sure everything matches.
Remember that php helps you by showing you the line that it falls over at. Check line 33 of your test_db.php file. Can you paste your query for us ?
I just hope that before he learns anything, he had changed the account to his db, otherwise some dubious individuals might do some well, dubious things