chris_rulez001 Posted August 17, 2007 Share Posted August 17, 2007 hi, can someone help me with this please? code: <?php $host="localhost"; // Host name $username="########"; // Mysql username $password="#########"; // Mysql password $db_name="#######"; // Database name $tbl_name1="users"; // Table name $username2 = $_SESSION['username']; // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql1="SELECT * FROM $tbl_name1 WHERE username='$username2'"; // OREDER BY id DESC is order result by descending $result1=mysql_query($sql1); $rows1=mysql_fetch_array($result1); ?> <table cellpadding="4" cellspacing="1" border="0" width="100%"> <tr> <td style='background-color: #FFFFFF'> <?php $username1 = $_SESSION['username']; $userlevel = $rows1['usertype']; $page = $_REQUEST['action']; if (!isset($_SESSION['username']) == true) { echo "<strong>Error:</strong> <br/> You are not allowed to access the administration panel."; } else { if (!strpos($username1, $userlevel) == true) { echo "<strong>Error:</strong> <br/> You are not allowed to access the administration panel."; } else { echo "<a href='?action=create_board'>Create Board</a>"; // admin panel not finished } } ?> </td> </tr> </table> Quote Link to comment https://forums.phpfreaks.com/topic/65418-solved-mysql_fetch_array-error/ Share on other sites More sharing options...
kirk112 Posted August 17, 2007 Share Posted August 17, 2007 What error are you getting? if there is an error in the sql try changing $result1=mysql_query($sql1); to $result1=mysql_query($sql1) or die(mysql_error()); This will give you any error in the sql. Quote Link to comment https://forums.phpfreaks.com/topic/65418-solved-mysql_fetch_array-error/#findComment-326672 Share on other sites More sharing options...
chris_rulez001 Posted August 17, 2007 Author Share Posted August 17, 2007 What error are you getting? if there is an error in the sql try changing $result1=mysql_query($sql1); to $result1=mysql_query($sql1) or die(mysql_error()); This will give you any error in the sql. yes i did give me a error, i was querying a table that didnt exist. thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/65418-solved-mysql_fetch_array-error/#findComment-326680 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.