PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I've got a page to display some products, and I need it to display a new set of code if a product has an 'accessory'
I've added a TinyInt to my database and if its set 1 I want to display the new code, however the if statement I've put in just lags the page out and wont display at all (cannot display the webpage error)
(tried with and without quotes) but still nothing, pages just try and load and simply crash. I didn't think I needed any of that cos I'm pulling a tinyint from the server, so it can only be 1 number, and theres only 1 product on the page at any one time.
<?php
$sql = "SELECT accessory FROM ver_pro where pID='1' AND prCode = 1000107";
$result = mysql_query($sql);
$query_data = mysql_fetch_assoc($result);
if ($query_data == 1){
?>
// code to come
<?php
}
else {
echo 'hello';
}
?>
Thats what the codes like now, and I am jsut getting 'hello' posted on the page, but at least the page is loading. So its not recognising that it needs to only select accessory from the products table based on the product code / pId >.< very annoying... but I can't see why ?
If I add back in the [accessory] that was suggested before, the 'code to come' turns up, however... it turns up then on EVERY page, and it should only be on the one.
It was loading before... it just didnt have anything to display so you got a white screen.
$query_data is an array... thats how data is returned to you even if its only 1 variable. so where you put $query_data == 1... $query_data will never equal 1. $query_data will equal 'array' at best.
now you still have the problem that your returned recordset field called 'accessories' does NOT equal 1. thats why you are getting a blank page.
first things first... find out what MySQL is returning to you. remove your if statement and do the following.
Well at least somethings working.... I get Array ( [accessory] => 1 ) 1fail on the page WITH accessory set to 1 in the DB and Array ( [accessory] => 0 ) 1fail for the page without accessory set to 1... so its understanding that at least.