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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.