Jump to content

Recommended Posts

The following code is in a handling form,, but my query does not recognise the variable $x and outputs it on the screen wen the forms submitted as "array" when it should have a number in it...?

COMES UP WITH ERROR FOR THE QUERY IM USING

ArrayUnknown column 'Array' in 'where clause'

 

ne 1 help me is a STAR!!

 

 

 if ($_POST['sel_item_id'] != null) 
{
  echo $x = $_POST['sel_item_id'];


$get_iteminfo = "select productName from product where productId = $x"; 

Link to comment
https://forums.phpfreaks.com/topic/38210-im-sure-its-simple-for-u-guys/
Share on other sites

thanks for that ,, makes some sense, but if its non existent, how do i get the value from the post array ($_POST['sel_item_id']) and use it in my sql query to equal the product id? p.s. the value $_POST['sel_item_id'] is coming from the hidden value from a button being pressed...

okay erm let me try and show how the hidden input value is being used on the buttons im creating

 

for( $x=0; $x < $hidenval[$i]; $x++ ){

echo '<form method = post action="addtocart.php">';									

echo'<INPUT TYPE ="submit" name = "submit" value = "Add to Cart" maxlength "50">
<input type="hidden" name="sel_item_id[]" value="'.$hidenval[$i].'">';
}

:) SORRY IV JUST NOTICED A PROBLEM IN THIS LOOP - the value in the hidden input needs to be of the variable "$x"  not

value="'.$hidenval[$i].'">';  SO THE CORRECT LOOP NOW IM USING IS  but stil with an error

ArrayUnknown column 'Array' in 'where clause' in my sql query im using to check equality with product id>>HOPE THIS HELPS IM ONLINE NOW SO ASK ME NETHIN IL REPLY ASAP!

 

for( $x=0; $x < $hidenval[$i]; $x++ ){

 

echo '<form method = post action="addtocart.php">';

 

echo'<INPUT TYPE ="submit" name = "submit" value = "Add to Cart" maxlength "50">

<input type="hidden" name="sel_item_id[]" value="'.$x.'">';

}

OKAY I THINK IM SOLVING THIS MYSELF WITHOUT NE HELP BUT I THINK I STIL NEED HELP....Now from the changes iv made its working but not fully. Well no errors, before i was using a loop to make buttons but using the name to be an array to avoid re-writing of the name of the button...

<input type="hidden" name="sel_item_id[]" value="'.$x.'">';

 

This gives the error  "ArrayUnknown column 'Array' in 'where clause'"  in the handling form code where im using the query which is

 


if ($_POST['sel_item_id'] != null) 
{
   $x = $_POST['sel_item_id'];


$get_iteminfo = "select productName from product where productId = $x";
$get_iteminfo_res = mysql_query($get_iteminfo) or die(mysql_error());

 

 

but if i change the name to just a normal string as

 

<input type="hidden" name="sel_item_id" value="'.$x.'">';

 

the last value of the for loop is saved and so its re-writing which im trying to avoid it doing....is that better guys?  :'( :'( :'(

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.