Jump to content

[SOLVED] User Profiles


DeanWhitehouse

Recommended Posts

i get this error

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/www/deanwhitehouse.awardspace.co.uk/test/user_profile.php on line 9

 

with this code

<?php
require_once 'db_connect.php';
require_once 'nav_bar.php';
require_once 'logged_in.php';

$user_id = addslashes($_GET['id']);
$sql = "SELECT * FROM `$user` WHERE `id`='{$user_id}' LIMIT 1;";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$username = $row['user_name']

?>

Link to comment
Share on other sites

i get this error

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/www/deanwhitehouse.awardspace.co.uk/test/user_profile.php on line 9

 

with this code

<?php
require_once 'db_connect.php';
require_once 'nav_bar.php';
require_once 'logged_in.php';

$user_id = addslashes($_GET['id']);
$sql = "SELECT * FROM `$user` WHERE `id`='{$user_id}' LIMIT 1;";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$username = $row['user_name']

?>

That was sample code. is your DB set up that way?

Link to comment
Share on other sites

this code is right but, it doesn't display anything from the database

<?php
require_once 'db_connect.php';
require_once 'nav_bar.php';
require_once 'logged_in.php';

$user_id = addslashes($_GET['id']);
$sql = "SELECT * FROM `$user` WHERE `user_id`='{$user_id}' LIMIT 1;";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$username = $row['user_name']

?>

i tried changing it to this but, it still isn't displaying anything

<?php
require_once 'db_connect.php';
require_once 'nav_bar.php';
require_once 'logged_in.php';

$user_id = $_SESSION['user_id'];
$sql = "SELECT * FROM $user WHERE `user_id`='{$user_id}' LIMIT 0,1;";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$username = $row['user_name']

?>

do i need to echo it?

Link to comment
Share on other sites

no, db_connect.php has the session_start() on it also when i try to echo like this

<?php
require_once 'db_connect.php';
require_once 'nav_bar.php';
require_once 'logged_in.php';

$user_id = $_SESSION['user_id'];
$sql = "SELECT * FROM $user WHERE `user_id`='{$user_id}' LIMIT 0,1;";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$username = $row['user_name']

echo "$username";
?>

 

i get an "unexpected" error with this, it doesn't expect the echo

Link to comment
Share on other sites

<?php
require_once 'db_connect.php';
require_once 'nav_bar.php';
require_once 'logged_in.php';

$user_id = $_SESSION['user_id'];
$sql = "SELECT * FROM $user WHERE `user_id`='{$user_id}' LIMIT 0,1;";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$username = $row['user_name'];

echo "$username";
?>

forgot a ";"

Link to comment
Share on other sites

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.