Jump to content

Is this possible?


unistake

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.