SELECT * insted of typing all columns
Posted: Mon May 29, 2006 5:58 am
Hi Guys,
I'm back for more help.
I have always used SELECT Username, Password FROM table but I have loads of columns in this project and I didn't really want to type out each one so I thought of using SELECT * instead but it does not work.
Can anyone see why in my code below?
Thanks.
I'm back for more help.
I have always used SELECT Username, Password FROM table but I have loads of columns in this project and I didn't really want to type out each one so I thought of using SELECT * instead but it does not work.
Can anyone see why in my code below?
Thanks.
Code: Select all
<?php session_start();
include_once("includes/globals.php");
$email = $_POST['email'];
$password = $_POST['password'];
$live = "Active";
if(empty($email)){
include_once("error_pages/login_error.php");
exit();
}
elseif(empty($password)){
include_once("error_pages/login_error.php");
exit();
}
include_once("includes/connect.php");
$sql = "SELECT * FROM users WHERE email='$email' AND password='$password' AND status='$live'";
$r = mysql_query($sql);
if(!$r) {
$err=mysql_error();
print $err;
exit();
}
if(mysql_affected_rows()==0){
include_once("error_pages/index_error.php");
exit();
}
else{
}
while ($line = mysql_fetch_array($r))
{
extract($line);
}
$_SESSION['mycompanyname'] = $companyname;
$_SESSION['myfirstname'] = $firstname;
$_SESSION['mylastname'] = $lastname;
$_SESSION['myemail'] = $email;
$_SESSION['mypassword'] = $password;
$_SESSION['mysite'] = $site;
$_SESSION['mytitle'] = $title;
echo $_SESSION['mycompanyname'];
?>