p2grace
-
Posts
1,024 -
Joined
-
Last visited
Never
Posts posted by p2grace
-
-
Did you change the (int) to mysql_real_escape_string() as suggested by gevans?
-
that would do it
Out of curiosity does that throw a php error or simply convert it to 0?
-
Ok - assuming you're no longer getting the 'Category isn't specified' error... I'm not seeing where the $sitelocation variable is created, but it's being called in the echo string.
Is there any output at all? Any php errors?
-
Can you post the most recent version of your code again
-
It means that there is no "?cat=child" in the url. So the script attempts to pull the $_GET['cat'] but can't because the variable doesn't exist in the url.
You need to make sure the variable exists in the url before the script can pull the category and execute the query.
Make sense?
-
do an isset() to check if the field exists
if(!isset($_GET['cat'])){ die("Category isn't specified"); }
-
If echoing the $_GET['cat'] isn't displaying anything, then the variable?cat=child isn't accessible via the url. Could you paste the actual url (the actual results of your previous post) so I can confirm that the variable is present and rule that out as an issue.
-
No I mean the exact url that contains the $_GET['cat'] script.
So http://www.sample.com/filename.php?cat=3
Should be something like that... I want to confirm the $_GET vars.
-
Can you show us the exact url in the address bar for this page?
-
Does echoing the value of the $_GET var work?
echo $_GET['cat'];
If it doesn't then the $_GET var isn't accessible from the url.
-
Try the following, it'll display mysql errors and php errors.
<?php /* Enable displaying of errors */ error_reporting(E_ALL); ini_set('display_errors', 'On'); $cat = (int) $_GET['cat']; $get_items = "SELECT * FROM poj_products WHERE cat='$cat'"; $get_items = mysql_query($get_items); if($get_items){ $item_row = mysql_fetch_assoc($get_items); echo '<a href="'.$sitelocation.$item_row['url'].'?item_desc='.$item_row['id'].'>view details/order</a>'; }else{ die("Unable to connect to database.".mysql_error()); } ?>
-
That works too
-
You should also protect the $cat var from sql injection.
$cat = mysql_real_escape_string($_GET['cat']);
-
No problem... if it solves your issue, could you mark the topic as "solved"?
Cheers,
p2grace
-
Do you use google analytics (or any other visitor tracking service) to track website visitors?
-
-
Glad it helped you out... could you mark the topic as solved?
Cheers,
p2grace
-
lol - if your code is clean you shouldn't have any
-
Add this to the script:
<?php /* Enable displaying of errors */ error_reporting(E_ALL); ini_set('display_errors', 'On'); ?>
-
How about php errors?
-
I'd recommend checking if it returned a mysql error.
-
If your question has been answered could you also mark the post topic as "Solved"?
Cheers,
p2grace
-
An assignment only uses one equal sign.
if ($user['gender']=="m") {$user['gender']="Male";}
-
It isn't necessary if you are not actually returning a variable. It just acts as a void.
[SOLVED] Help needed with passing 'id' through url
in PHP Coding Help
Posted
The function is spelled wrong, should be: