melting_dog Posted July 17, 2010 Share Posted July 17, 2010 Hi all, I have a page that runs a query where users can send info via either a form (post) or from redirecting from another page (get). The get function uses: header("location:forumsDiscussion.php?$comDiscussNo"); to send content of the $comDiscussNo variable and appears to work fine: i can see the variable content in the URL. but when i put these into if statements it doesnt run. Heres the code: <?php $discussIDtrans = $_GET['$comDiscussNo']; if ($discussIDtrans = null) { $discussID=(int)$_POST['discussID']; } else { $discussID = $discussIDtrans; } $sql = "SELECT * FROM discussion WHERE discussID ='$discussID'"; ******ETC ETC ETC******* Anyone have any ideas why this isnt working? Cheers Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted July 17, 2010 Share Posted July 17, 2010 Your "if" statement is incorrect. Use one "=" for assignment, two "==" for comparison. Ken Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted July 17, 2010 Share Posted July 17, 2010 again this part look suspicious $discussID=(int)$_POST['discussID']; you are using header() so use $_GET instead of $_POST Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted July 17, 2010 Share Posted July 17, 2010 I am not sure what is $comDiscussNo but i only guess that it is comDiscussNo=blablabla header("location:forumsDiscussion.php?$comDiscussNo"); $_GET['$comDiscussNo']; so bold part also wrong should be $_GET['comDiscussNo']; Quote Link to comment Share on other sites More sharing options...
melting_dog Posted July 17, 2010 Author Share Posted July 17, 2010 Thanks guys. i fixed the if statement and using an alert box narrowed the problem down to the get: although the correct variable content is shown in the URL it is not reaching the page: $_GET['comDiscussNo']; has nothing in it (even after changing it like robert suggested). Anyone got any other ideas? Thanks Quote Link to comment Share on other sites More sharing options...
melting_dog Posted July 17, 2010 Author Share Posted July 17, 2010 Thanks guys. i fixed the if statement and using an alert box narrowed the problem down to the get: although the correct variable content is shown in the URL it is not reaching the page: $_GET['comDiscussNo']; has nothing in it (even after changing it like robert suggested). Anyone got any other ideas? Thanks ...but this is also strange because even if $_GET['comDiscussNo']; has nothing in it the if statement: $discussIDtrans = $_GET['comDiscussNo']; $discussIDpost =(int)$_POST['discussID']; if ($discussIDtrans == null) { $discussID = $discussIDpost; } else { $discussID = $discussIDtrans; } should just pass it on to the else statement, making $discussID equal to the POST weird... Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted July 17, 2010 Share Posted July 17, 2010 try change this: if ($discussIDtrans == null) with this if(empty($discussIDtrans)){ Quote Link to comment Share on other sites More sharing options...
melting_dog Posted July 17, 2010 Author Share Posted July 17, 2010 try change this: if ($discussIDtrans == null) with this if(empty($discussIDtrans)){ Thanks heaps Robert, that has fixed the problem of $_GET['comDiscussNo']; being null. But any suggestions on why the $_GET isnt working? Cheers again! Quote Link to comment Share on other sites More sharing options...
robert_gsfame Posted July 17, 2010 Share Posted July 17, 2010 I only use null when it comes to query not for if statement Quote Link to comment 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.