unistake Posted October 17, 2010 Share Posted October 17, 2010 Hi all, I am not sure if these two lines are possible below? It does not seem to be working but I don't understand why? <?php $sql = "SELECT * FROM sales WHERE email='$email' AND reg='$reg'"; // IS THIS LINE POSSIBLE? $result = mysqli_query($cxn,$sql) or die ("Couldn't execute query"); while($row = mysqli_fetch_assoc($result)) { if ($row['reg'] == $_GET['reg'] && $row['email]' == $email) // AND THIS ONE? { echo $row['reg'] . " is registered by you!"; ?> Quote Link to comment Share on other sites More sharing options...
jl5501 Posted October 17, 2010 Share Posted October 17, 2010 Assuming your $reg and $email variables exist, and have values compatible with the types of the table elements of the same name, and you have $_GET['reg'] then there should not be a problem Quote Link to comment Share on other sites More sharing options...
unistake Posted October 17, 2010 Author Share Posted October 17, 2010 OK Thanks. Some reason it is not working. I have checked the two variables which work but the script just produces a blank page. the full code is: <?php $email = $_SESSION['logname']; $reg = $_GET['reg']; $sql = "SELECT * FROM sales WHERE email='$email' AND reg='$reg'"; $result = mysqli_query($cxn,$sql) or die ("Couldn't execute query"); while($row = mysqli_fetch_assoc($result)) { if ($row['reg'] == $_GET['reg'] && $row['email]' == $email) { echo $row['reg'] . " is registered by you!"; } else { echo "I am sorry but the $_GET[reg] does not seem to be registered by you!"; exit(); } } ?> Quote Link to comment Share on other sites More sharing options...
jl5501 Posted October 17, 2010 Share Posted October 17, 2010 The blank page is likely to be a syntax error of some sort. You need to turn error reporting on for this page to see what php is complaining about. http://php.net/manual/en/function.error-reporting.php Quote Link to comment Share on other sites More sharing options...
unistake Posted October 17, 2010 Author Share Posted October 17, 2010 where abouts would I put error_reporting(0); I can not get it to work. Quote Link to comment Share on other sites More sharing options...
jl5501 Posted October 17, 2010 Share Posted October 17, 2010 you do not want (0) as that turns off error reporting, but you need it as the first line of your script. <?php error_reporting(E_ALL); ini_set("display_errors", 1); ?> Quote Link to comment Share on other sites More sharing options...
unistake Posted October 17, 2010 Author Share Posted October 17, 2010 I put that at the top of the page but still does not show anything!? Quote Link to comment Share on other sites More sharing options...
litebearer Posted October 17, 2010 Share Posted October 17, 2010 We are presuming that although you state 'full code' you haven't shown us the portion where you (1) start sessions, and (2) connect to the database. try this... <?php /* make sure you start sessions here */ /* make sure you connect to the database here */ $email = $_SESSION['logname']; $reg = $_GET['reg']; $sql = "SELECT * FROM sales WHERE email='$email' AND reg='$reg'"; $result = mysqli_query($cxn,$sql) or die ("Couldn't execute query"); $row_cnt = 0; $row_cnt = mysqli_num_rows($result); if($row_cnt>0) { echo "FOUND"; }else{ echo "NOT FOUND"; } echo "<br>"; echo $reg . " has " . strlen($reg) . " characters<br>"; echo $email . " has " . strlen($email) . " characters<br>"; ?> Quote Link to comment Share on other sites More sharing options...
unistake Posted October 17, 2010 Author Share Posted October 17, 2010 Works perfectly thanks 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.