Jump to content

[SOLVED] user profile help


rallokkcaz

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/48369-solved-user-profile-help/
Share on other sites

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"); 
?>

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';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.