Jump to content

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/65418-solved-mysql_fetch_array-error/
Share on other sites

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

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.