Jump to content

understanding error message


mindapolis

Recommended Posts

can someone help me why I'm getting this error message with the below code.  The code in its entirity should be attached. 

 

Query Error : Unknown column 'customers_id' in 'where clause'


if((isset($_REQUEST["submit"]) && $_REQUEST["submit"]=="Log in") || $_SESSION['user']){

if(!$_SESSION['user']){
	$login_username = isset($_REQUEST["username"])?$_REQUEST["username"]:"";
	$login_password = isset($_REQUEST["password"])?$_REQUEST["password"]:"";

	$msg = array();
	if ($login_username == "")
		$login_msg['username_empty'] = "Please enter your name";
	if ($login_password == "")
		$login_msg['password_empty'] = "Please enter your password";			

	$query = "SELECT * FROM customers WHERE username = '$login_username' AND password = '".$login_password."'";
}else{
	$customer_id = $_SESSION['user'];
	$query = "SELECT * FROM customers WHERE customer_id='$customer_id'";
}

if (!$login_msg){

	$login_process = true;

	$result = mysql_query($query) or die("Database error: " . mysql_error());

	if (mysql_num_rows($result) > 0){
		$row = mysql_fetch_object($result);
		$customer_id = $row->customer_id;
'			$_SESSION['user'] = $customer_id; 
		$fname = $row->fname;
		$lname = $row->lname;
		$username=$row->username;
		$address=$row->address;
		$state=$row->state;
		$city=$row->city;
		$zip=$row->zip;
		$phone=$row->phone;
		$fax=$row->fax;
		$email =$row->email;
		$payment = $row->payment_method;
		$paypal_username=$row->paypal_username;
		$ship_first_name=$row->ship_first_name;
		$ship_last_name=$row->ship_last_name;
		$ship_address=$row->ship_address;
		$ship_city=$row->ship_city;
		$ship_state=$row->ship_state;
		$ship_zip=$row->ship_zip;
		$ship_email=$row->ship_email;
		$pet_name=$row->pet_name;
		$age=$row->age;
		$breed=$row->breed;
            $pet_name2=$row->pet_name2;
		$age2=$row->age2;
		$breed2=$row->breed2;

	}else{
		$login_msg['login_fail'] = "Username, password combination is not valid.";
	}
}
}
if(isset($_REQUEST["submit"]) && $_REQUEST["submit"]=="submit"){
$msg=array();
$fname=isset($_REQUEST["fname"])?$_REQUEST["fname"]:"";
$lname=isset($_REQUEST["lname"])?$_REQUEST["lname"]:"";
$username=isset($_REQUEST["lname"])?$_REQUEST["username"]:""; 
$password=isset($_REQUEST["lname"])?$_REQUEST["password"]:"";
$reenterPassword=isset($_REQUEST["lname"])?$_REQUEST["reenterPassword"]:"";
$address=isset($_REQUEST["address"])?$_REQUEST["address"]:"";
$state=isset($_REQUEST["state"])?$_REQUEST["state"]:"";
$city=isset($_REQUEST["city"])?$_REQUEST["city"]:"";
$zip=isset($_REQUEST["zipcode"])?$_REQUEST["zipcode"]:"";
$phone=isset($_REQUEST["phone"])?$_REQUEST["phone"]:"";
$fax=isset($_REQUEST["fax"])?$_REQUEST["fax"]:"";
$email =isset($_REQUEST["email"])?$_REQUEST["email"]:"";
$re_enter_email =isset($_REQUEST["re_email"])?$_REQUEST["re_email"]:"";
$re_enter_email= $email; 
$payment = isset($_POST['payment_Method'])?$_POST['payment_Method']:""; 
$paypal_username=isset($_REQUEST["PayPal_username"])?$_REQUEST["PayPal_username"]:"";
$ship_first_name=isset($_REQUEST["Shipfname"])?$_REQUEST["Shipfname"]:"";
$ship_last_name=isset($_REQUEST["Shiplname"])?$_REQUEST["Shiplname"]:"";
$ship_address=isset($_REQUEST["Shipaddress"])?$_REQUEST["Shipaddress"]:"";
$ship_city=isset($_REQUEST["Shipcity"])?$_REQUEST["Shipcity"]:"";
$ship_state=isset($_REQUEST["Shipstate"])?$_REQUEST["Shipstate"]:"";
$ship_zip=isset($_REQUEST["Shipzipcode"])?$_REQUEST["Shipzipcode"]:"";
$ship_email=isset($_REQUEST["Shipemail"])?$_REQUEST["Shipemail"]:"";
$ship_re_email=$ship_email;

    $pet_name=isset($_REQUEST["petName"])?$_REQUEST["petName"]:"";
$age=isset($_REQUEST["age"])?$_REQUEST["age"]:1;
$breed=isset($_REQUEST["breed"])?$_REQUEST["breed"]:"";
$nutritional_needs=isset($_REQUEST["nutritionalNeeds"])?$_REQUEST["nutritionalNeeds"]:"";
    $special_instructions=isset($_REQUEST["specialInstructions"])?$_REQUEST["specialInstructions"]:"";

    $pet_name2=isset($_REQUEST["petName2"])?$_REQUEST["petName2"]:"";
$age2=isset($_REQUEST["age2"])?$_REQUEST["age2"]:"";
$breed2=isset($_REQUEST["breed2"])?$_REQUEST["breed2"]:"";
$nutritional_needs2=isset($_REQUEST["nutritionalNeeds2"])?$_REQUEST["nutritionalNeeds2"]:"";
$special_instructions2=isset($_REQUEST["specialInstructions2"])?$_REQUEST["specialInstructions2"]:"";

// Products information

$product_name=isset($_REQUEST["productname"])?$_REQUEST["productname"]:"";
$quantity=isset($_REQUEST["quantity"])?$_REQUEST["quantity"]:0;
$price=isset($_REQUEST["price"])?$_REQUEST["price"]:0;
$quantity_diff=isset($_REQUEST["quantity_diff"])?$_REQUEST["quantity_diff"]:0;
$price_diff=isset($_REQUEST["price_diff"])?$_REQUEST["price_diff"]:0;
$sales_tax=isset($_REQUEST["salestax"])?$_REQUEST["salestax"]:0; 
$subtotal=isset($_REQUEST["subtotal"])?$_REQUEST["subtotal"]:0;
$shipping_cost=isset($_REQUEST["shippingcost"])?$_REQUEST["shippingcost"]:0;
$total=isset($_REQUEST["total"])?$_REQUEST["total"]:0;


// check for login

if(isset($_POST['customer_id'])){
	$customer_id = $_POST['customer_id'];
	$query = "SELECT * FROM customers WHERE customer_id='$customer_id'";
	$result = mysql_query($query) or die("Database error: " . mysql_error());
	if (mysql_num_rows($result) > 0){
		$login_process = true;
		$_SESSION['user'] = $customer_id;
		$row = mysql_fetch_object($result);
		$fname = $row->fname;
		$lname = $row->lname;
		$username=$row->username;
	}
}

// Is username taken ?

if(!$login_process){

	$query = "SELECT * FROM customers WHERE username = '$username'";
	$result = mysql_query($query) or die("Database error: " . mysql_error());
	if (mysql_num_rows($result) > 0){
		array_push($msg,"This username is already taken, please choose another one.");
	}
}

<div id="login">   

<form action="" method="post" name="login">

<?php if (isset($login_msg['login_fail'])) ?>

<?='<p>'.$login_msg['login_fail'].'</p>'?>

<?php if (isset($login_msg['username_empty'])) ?>

<?='<p>'.$login_msg['username_empty'].'</p>'?>

<?php if (isset($login_msg['password_empty'])) ?>

<?='<p>'.$login_msg['password_empty'].'</p>'?>

    <?php if(!$_SESSION['user']){ ?>

    <table border="0">

    <tr><td><b>Username</b></td><td><input name="username" type="text" size="15" maxlength="20" /></td></tr>

    <tr><td><b>Password</b></td><td><input name="password" type="password" size="15" maxlength="20" /></td></tr>

    <tr><td colspan="2"><input name="submit" type="submit" value="Log in" /></td></tr>

    </table>

    <?php

}else{

	echo 'Welcome, '.$fname.'<br/><input type="submit" name="logout" value="Logout"/>';

}

$query = "SELECT * FROM treats"; 

$result_set = mysql_query($query) or die(mysql_error());

while ($row = mysql_fetch_array($result_set)){

    	if($_POST["quantity".$row["product_id"]]!=""){?>

	<input type="hidden" name="quantity<?php echo $row['product_id']; ?>" value="<?php echo $_POST["quantity".$row["product_id"]];?>"/>

        

<?php }} ?>

</form>

</div>

18073_.php

Link to comment
Share on other sites

You need to identify which specific query is causing the error and post just that, as well as the details for the tables involved (list of columns and their types, mainly).  The code you posted has several queries, we have no way of knowing which of them (if any of them) is the problem query or why. 

 

You say your getting an unknown column error, that means one of your queries is attempting to use a column name that does not exist.  In the error you posted it says customers_id, but in the first couple place I see in your code, you use the column named customer_id (no s).  Probably you just made a small typo in one of your queries somewhere.

 

Link to comment
Share on other sites

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.