PHP CMS USER AREA PAGE

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
evanleondawod
Forum Newbie
Posts: 8
Joined: Sat Mar 28, 2009 1:04 pm

PHP CMS USER AREA PAGE

Post by evanleondawod »

hi everybody.. I am currently creating a CMS site... and all is going well. i am having a few issues with the user area page.

I have created a page (code below) and want to display the users username, amongst other details that i have stored on a SQL database.

when i upload this page i receive this error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/edawod/public_html/platform/userarea.php on line 39

CODE:

<? session_start();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>BU | The Station</title>
<link href="Stylesheets/text.css" rel="stylesheet" type="text/css" />
</head>
<body>

<div id="content">
<div id="headPanel">
<table width="900">
<tr>
<td width="900" height="135">
</td>
</tr>
<tr>
<td width="900" class="links">
<form class="searchbox" name="form" action="search.php" method="get">
<input class="searchfield" type="text" name="q" />
<input type="submit" name="Submit" value="Search" /><br />
</form>
<a class="links" href="index.php">Home -</a> <a href="videos.php">Videos -</a> <a href="members.php">Members</a>
</td>
</tr>
</table>
</div>

<div id="bodyPanel">
<table width="900">
<tr>
<td class="profilefields" width="300">
<?
if (isset($_SESSION['username'])) { // if they are logged in, show the form

$theUser = $_SESSION['username']; // get their username from the session
$result = mysql_query("SELECT * FROM users WHERE username = '$theUser'"); // select their record from the table
$info = mysql_fetch_array($result); // parse their info into an array ***THIS IS LINE 39 - The line with the error***
?>

<h1>
<? echo $info['username']; ?>
</h1>
<img src="<? echo $info['pic']; ?>" /><br /><br />
Status:<br /><br />
Location:<br /><br />
Age:<br /><br />
E-mail:<? echo $info['email']; ?><br /><br />
FaceBook:<br /><br />
Twitter:<br /><br />
</td>
<td class="profilefields" width="300">
<h1>Tools</h1>
<a href="editProfile.php">Edit Profile</a><br /><br />
<a href="viewProfile.php">View Profile</a><br /><br />
<a href="uploadImages.php">Upload Images</a><br /><br />
<a href="uploadVideos.php">Upload Videos</a><br /><br />
<h2>Shouts!</h2>
<? if (isset($_SESSION['username'])) { // makes sure that someone is logged in before they can comment ?>

Hey <? echo $_SESSION['username']; ?>, leave a comment!
<form action="add-comment.php" method="post">
<input type="hidden" name="username" value="<? echo $_SESSION['username']; ?>" />
<input type="hidden" name="date" value="<? echo date("d / m / y"); ?>" />
<input type="hidden" name="ref" value="<? echo $_GET['id']; ?>" />
<p>Comment: <br />
<textarea name="comment" cols="40" rows="3"></textarea></p>
<p><input type="submit" name="submit" value="Post" /></p>
</form>
<? } ?>
<? } ?>
</td>
<td width="300">
<h1>Uploaded Videos</h1>
<h2>Uploaded Images</h2>
</td>
</tr>
</table>
</div>
<div id="lowPanel">
<table width="900">
<tr>
<td>
<h3>Bournemouth Media School | Sitemap | Contact Us</h3>
</td>
</tr>
</table>
</div>
</div>


</body>
</html>

any advice or tips would be really helpful.. because i have not been able to troubleshoot the error...

Thanks...
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: PHP CMS USER AREA PAGE

Post by McInfo »

Where is your database connection?

Please use tags when posting code.

Edit: This post was recovered from search engine cache.
Last edited by McInfo on Thu Jun 17, 2010 1:28 pm, edited 1 time in total.
evanleondawod
Forum Newbie
Posts: 8
Joined: Sat Mar 28, 2009 1:04 pm

Re: PHP CMS USER AREA PAGE

Post by evanleondawod »

hi

sorry im new to this forum...

I have file called connection.php on my server... do i need to type at the top of the page?:

Code: Select all

 
<?php require ("connection.php"); ?>
 
thanks
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: PHP CMS USER AREA PAGE

Post by McInfo »

Yes.

Edit: This post was recovered from search engine cache.
Last edited by McInfo on Thu Jun 17, 2010 1:29 pm, edited 1 time in total.
evanleondawod
Forum Newbie
Posts: 8
Joined: Sat Mar 28, 2009 1:04 pm

Re: PHP CMS USER AREA PAGE

Post by evanleondawod »

thanks mate... i was being stupid
Post Reply