ali_2kool2002 Posted February 12, 2007 Share Posted February 12, 2007 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"; Quote Link to comment https://forums.phpfreaks.com/topic/38210-im-sure-its-simple-for-u-guys/ Share on other sites More sharing options...
wildteen88 Posted February 12, 2007 Share Posted February 12, 2007 Why are you echo'ing the $x variable when you are setting it? Remove the echo. You cant echo a variable when you are creating it. Quote Link to comment https://forums.phpfreaks.com/topic/38210-im-sure-its-simple-for-u-guys/#findComment-182973 Share on other sites More sharing options...
trecool999 Posted February 12, 2007 Share Posted February 12, 2007 You're echoing a non-existant variable ($x). $x = $_POST['sel_item_id']; if ($_POST['sel_item_id'] != null) { echo $x; $get_iteminfo = "select productName from product where productId = $x"; Quote Link to comment https://forums.phpfreaks.com/topic/38210-im-sure-its-simple-for-u-guys/#findComment-182975 Share on other sites More sharing options...
ali_2kool2002 Posted February 13, 2007 Author Share Posted February 13, 2007 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... Quote Link to comment https://forums.phpfreaks.com/topic/38210-im-sure-its-simple-for-u-guys/#findComment-183552 Share on other sites More sharing options...
ali_2kool2002 Posted February 13, 2007 Author Share Posted February 13, 2007 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].'">'; } Quote Link to comment https://forums.phpfreaks.com/topic/38210-im-sure-its-simple-for-u-guys/#findComment-183556 Share on other sites More sharing options...
ali_2kool2002 Posted February 13, 2007 Author Share Posted February 13, 2007 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.'">'; } Quote Link to comment https://forums.phpfreaks.com/topic/38210-im-sure-its-simple-for-u-guys/#findComment-183562 Share on other sites More sharing options...
ali_2kool2002 Posted February 13, 2007 Author Share Posted February 13, 2007 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? :'( :'( :'( Quote Link to comment https://forums.phpfreaks.com/topic/38210-im-sure-its-simple-for-u-guys/#findComment-183566 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.