rallokkcaz Posted April 23, 2007 Share Posted April 23, 2007 im currently working on a user profile code in PHP and i keep getting these annoying errors can anyone help? here is the code <?php include ("http://www.getmetola.com/config.php"); if(isset($_GET['id']) && is_numeric($_GET['id'])) { $id = $_GET['id']; $get['userdata'] = mysql_query("SELECT * FROM users WHERE id='$id'"); $get['userdata'] = mysql_fetch_array($get['userdata']); echo '<font family="Georgia"> <center> <table> <tr><td align=\"left\" bgcolor="#e5e5e5"> Username: ' .$get['userdata']['username'] .'<br> </tr></td> <tr><td align=\"left\" bgcolor="#FFFFFF"> About Me: ' .$get['userdata']['aboutme'] .'<br> </tr></td> <tr><td align=\"left\" bgcolor="#e5e5e5"> Likes: ' .$get['userdata']['likes'].'<br> </tr> </td> <tr><td align=\"left\" bgcolor="#FFFFFF"> Hates: ' .$get['userdata']['hates'].' </tr></td> </table>'; } else { //########REDIRECTS TO YOUR HOME PAGE IF UID IS NOT PRESENT IN THE URL######### echo '<meta http-equiv="refresh" content="0;URL=http://www.getmetola.com/people.php" />'; } ?> and the errors i get are Warning: mysql_query() [function.mysql-query]: Access denied for user 'pokebash'@'localhost' (using password: NO) in /home/pokebash/public_html/getmetola/profile/default.html on line 7 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/pokebash/public_html/getmetola/profile/default.html on line 7 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pokebash/public_html/getmetola/profile/default.html on line 9 can anyone help? thanks! Quote Link to comment https://forums.phpfreaks.com/topic/48369-solved-user-profile-help/ Share on other sites More sharing options...
john010117 Posted April 23, 2007 Share Posted April 23, 2007 That means that your username/password to link to the MySQL database is incorrect. Make sure you have the right user/pass. Your connection code should look something like this: <?php // Connect to the database $host = "localhost"; // db host $user = "***"; // db username $pass = "***"; // db password $db = "***"; // db name $connection = mysql_connect ($host, $user, $pass) or die ("Unable to connect"); mysql_select_db ($db) or die ("Unable to select database"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/48369-solved-user-profile-help/#findComment-236475 Share on other sites More sharing options...
trq Posted April 23, 2007 Share Posted April 23, 2007 The first problem is your connection fails. The rest all spill over from that because you have no error handling in place. Any reason your using a url instead of a file path to call your config.php file? (Assuming thats where your connection details are, use require() to make sure it is being included. require 'config.php'; Quote Link to comment https://forums.phpfreaks.com/topic/48369-solved-user-profile-help/#findComment-236476 Share on other sites More sharing options...
rallokkcaz Posted April 23, 2007 Author Share Posted April 23, 2007 Thorpe: im using a url because im in a subdirectory of my domain called profile John: so should i just redo the connect script in the file or should i fix the old on because i know the other one works Quote Link to comment https://forums.phpfreaks.com/topic/48369-solved-user-profile-help/#findComment-236478 Share on other sites More sharing options...
john010117 Posted April 23, 2007 Share Posted April 23, 2007 If you have a script that works on other places, leave it (just check the user/pass/db/host to see that they're 100% correct. Quote Link to comment https://forums.phpfreaks.com/topic/48369-solved-user-profile-help/#findComment-236480 Share on other sites More sharing options...
rallokkcaz Posted April 23, 2007 Author Share Posted April 23, 2007 ive just checked and it works so what could be the issue? or should i just set it again Quote Link to comment https://forums.phpfreaks.com/topic/48369-solved-user-profile-help/#findComment-236481 Share on other sites More sharing options...
trq Posted April 23, 2007 Share Posted April 23, 2007 im using a url because im in a subdirectory of my domain called profile Whats wrong with... require '../config.php'; ? Quote Link to comment https://forums.phpfreaks.com/topic/48369-solved-user-profile-help/#findComment-236483 Share on other sites More sharing options...
rallokkcaz Posted April 23, 2007 Author Share Posted April 23, 2007 thorpe!! thanks that completly fixed it! thanks for all the help guys!!!! Quote Link to comment https://forums.phpfreaks.com/topic/48369-solved-user-profile-help/#findComment-236484 Share on other sites More sharing options...
trq Posted April 23, 2007 Share Posted April 23, 2007 Of course it did. Quote Link to comment https://forums.phpfreaks.com/topic/48369-solved-user-profile-help/#findComment-236486 Share on other sites More sharing options...
rallokkcaz Posted April 23, 2007 Author Share Posted April 23, 2007 yes i know it was a stupid mistake Quote Link to comment https://forums.phpfreaks.com/topic/48369-solved-user-profile-help/#findComment-236491 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.