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!"; ?> Link to comment https://forums.phpfreaks.com/topic/216063-is-this-possible/ 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 Link to comment https://forums.phpfreaks.com/topic/216063-is-this-possible/#findComment-1122914 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(); } } ?> Link to comment https://forums.phpfreaks.com/topic/216063-is-this-possible/#findComment-1122915 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 Link to comment https://forums.phpfreaks.com/topic/216063-is-this-possible/#findComment-1122919 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. Link to comment https://forums.phpfreaks.com/topic/216063-is-this-possible/#findComment-1122920 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); ?> Link to comment https://forums.phpfreaks.com/topic/216063-is-this-possible/#findComment-1122925 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!? Link to comment https://forums.phpfreaks.com/topic/216063-is-this-possible/#findComment-1122926 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>"; ?> Link to comment https://forums.phpfreaks.com/topic/216063-is-this-possible/#findComment-1122927 Share on other sites More sharing options...
unistake Posted October 17, 2010 Author Share Posted October 17, 2010 Works perfectly thanks Link to comment https://forums.phpfreaks.com/topic/216063-is-this-possible/#findComment-1122928 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.