Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.