Forum Moderators: coopster
<?php
//error_reporting(E_ALL|E_STRICT);
require_once("Connections/connection.php"); // Connection to the server
$tbl_name="users"; // Deinfe the table name
session_start();
//include("includes/security.php"); //Link to the security file
$id = $_SESSION['id'];
/////////////////////////////////////////////////////////////////////////
$query = sprintf("SELECT * FROM users WHERE username='$id'");
$result = @mysql_query($query);
$rowAccount = @mysql_fetch_array($result);
/////////////////////////////////////////////////////////////////////////
?>
<div id="user_box">
<?php
if($id) {
echo 'Logged in as' $rowAccount['username'];
<input type="button" name="Button" value="Logout" onclick="document.location.href='logout.php'"/>
}
elseif($id()) {
exit;
}
?>
</div>
<div id="user_box">
<?php
if($id>0) {
echo 'Logged in as '. $rowAccount['username'];
echo '<input type="button" name="Button" value="Logout" onclick="document.location.href=\'logout.php\'"/>';
}
?>
</div>
$query = sprintf("SELECT * FROM users WHERE username='$id'");
$result = @mysql_query($query);<-- Remove the @ from here!
$rowAccount = @mysql_fetch_array($result);<-- Remove the @ from here!
$query = "SELECT * FROM `users` WHERE `username` = '".$id."' ";
$result = mysql_query($query) or die("Query error:".mysql_error());
$rowAccount = mysql_fetch_array($result) or die("Fetch Array Error:".mysql_error());
elseif($id()) {
exit;
}
if($id>0)? if($id>0)!
<?php {
echo 'Logged in as '. $rowAccount['username'];
echo '<input type="button" name="Button" value="Logout" onclick="document.location.href=\'logout.php\'"/>';
}
?>
<?php
//error_reporting(E_ALL|E_STRICT);
require_once("Connections/connection.php");
session_start();
$tbl_name="users";
//include("includes/security.php");
$id = $_SESSION['id'];
$query = "SELECT * FROM `users` WHERE `username` = '".$id."' ";
$result = mysql_query($query) or die("Query error:".mysql_error());
$rowAccount = mysql_fetch_array($result) or die("Fetch Array Error:".mysql_error());
?>
if($id>0)
if(isset($_SESSION['id']) && !empty($_SESSION['id'])){
your code
}
else{
//the $_SESSION['id'] wasn't located in the DB, redirect back login...
]
or die("Fetch Array Error:".mysql_error()) then everything works fine, do you know why this would be?
<?php
//error_reporting(E_ALL|E_STRICT);
require_once("Connections/connection.php"); // Connection to the server
session_start();
$tbl_name="users"; // Define the table name
//include("includes/security.php"); //Link to the security file
$id = $_SESSION['id'];
////////////////////////////////////////////////////////////////////////////////////
$query = "SELECT * FROM `users` WHERE `username` = '".$id."' ";
$result = mysql_query($query) or die("Query error:".mysql_error());
$rowAccount = mysql_fetch_array($result);
////////////////////////////////////////////////////////////////////////////////////
?>
<div id="user_box">
<?php
//if($id!=""){
//echo 'Logged in as: '. $rowAccount['username'];
//echo '<input type="button" name="Button" value="Logout" onclick="document.location.href=\'logout.php\'"/>';
//}
if(isset($_SESSION['id']) && !empty($_SESSION['id'])){
echo 'Logged in as '. $rowAccount['username'];
echo '<input type="button" name="Button" value="Logout" onclick="document.location.href=\'logout.php\'"/>';
}
?>
</div>
It appears that if I take out or die("Fetch Array Error:".mysql_error()) then everything works fine, do you know why this would be?