edot Posted November 2, 2009 Share Posted November 2, 2009 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 create 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... Link to comment https://forums.phpfreaks.com/topic/180004-cms-userarea-page/ Share on other sites More sharing options...
JAY6390 Posted November 2, 2009 Share Posted November 2, 2009 Do some debugging on your code change it to $theUser = $_SESSION['username']; // get their username from the session $query = "SELECT * FROM users WHERE username = '$theUser'"'; $result = mysql_query($query); if(!$result) { echo $query.'<br />'.mysql_error(); } Link to comment https://forums.phpfreaks.com/topic/180004-cms-userarea-page/#findComment-949666 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.