Jump to content

I'm not laughing!


FinalFrontier

Recommended Posts

I just wrote this small piece of code and not getting a result from it and wonder if someone could shed some light.

 

$query = "SELECT * FROM orders WHERE customeremail = '".mysql_real_escape_string($_POST['customere-mail'])."'"; $result = mysql_query($query); $row = mysql_fetch_array($result); mysql_query ($query);
if ($row['customeremail'] != "") {
foreach ($row['id'] as $whatever) {
	echo "lol";
}
}

 

I have two $row['id']'s, yet I am not getting any lols. Does anyone know why?

Link to comment
Share on other sites

$cemail = mysql_real_escape_string($_POST['customere-email']);
$query = "SELECT * FROM orders WHERE customeremail = '{$cemail}'";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
    if ($row['customeremail'] != "") {
    foreach ($row['id'] as $whatever) {
	    echo "lol";
	    }
    }
}

 

Try that code. Untested, but should work.

Link to comment
Share on other sites

So, I tried your suggestion, but still got the same result. :(

 

$query = "SELECT * FROM orders WHERE customeremail = '".mysql_real_escape_string($_POST['customere-mail'])."'"; $result = mysql_query($query); $row = mysql_fetch_array($result); mysql_query ($query);
if ($row['customeremail'] != "") {
while (mysql_fetch_array($result)) {
	echo "lol";
}
}

Link to comment
Share on other sites

This is beyond a fricken joke!!!!!! Ok, here is the code. And a friendly note. Please don't criticize my 'inefficiency' of code. I really don't care right now and all it does is frustrate me. I won't respond to critisizsm that is not in relation to this problem.

I am just trying to find out why this isn't working. Here is the full source code of the entire page and the problem is at line 6. The problem is that "LOL" is not echoing. If I remove the while() the $row echo's fine. But why isn't it working in a while() string?:

 

<?php
session_start();
$link = mysql_connect('localhost', 'testusr', 'testpw'); mysql_select_db('testdb', $link);
$query = "SELECT * FROM orders WHERE customeremail = '".mysql_real_escape_string($_POST['customere-mail'])."'"; $result = mysql_query($query); $row = mysql_fetch_array($result); mysql_query ($query);
if ($row['customeremail'] != "") {
	while (mysql_fetch_array($result)) {
		echo "LOL";
	}
	$subject = "Lay-by password recovery";
	if ($row['customertitle'] != "") {
		$customer = $row['customertitle']." ".$row['customerlastname'];
	} else {
		$customer = $row['customerfirstname'];
	}
	$body = "	Dear ".$customer."



			I received a request from the IP address ".$_SERVER['SERVER_ADDR']." for lay-by access recovery on your lay-by.


			Your lay-by access information:


			".$accessinformation."



			Kind regards,";
	$header = 'From: A B <me@example.com>';
	// mail($_POST['customere-mail'], $subject, $body, $header);
	$result = '
			<FORM action="../" style="left: 50%; margin-left: -22px; margin-top: -5px; position: absolute; text-align: center; top: 50%">
				<DIV>
					Done.
					<BR>
					<BR>
					<INPUT class="verdana" type="submit" value="OK">
				</DIV>
			</FORM>
	';
} else {
	$result = '
			<FORM action="../" style="left: 50%; margin-left: -160px; margin-top: -5px; position: absolute; text-align: center; top: 50%">
				<DIV>
					'.$_POST['customere-mail'].' was not found in the lay-by database.
					<BR>
					<BR>
					<INPUT class="verdana" type="submit" value="OK">
				</DIV>
			</FORM>
	';
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<TITLE>My Site</TITLE>
<META content="charset=windows-1252;text/html" http-equiv="content-type">
<LINK href="../../css/body.css" rel="stylesheet" type="text/css">
<STYLE type="text/css">
A.gold {
	color: rgb(255,215,0)
}
DIV.path {
	left: 50%;
	margin-left: -565px;
	margin-top: -266px;
	position: absolute;
	top: 50%
}
</STYLE>
<DIV>
<IMG alt="" class="logo" src="../../images/structural/logo.png">
<DIV class="customermenu"><?php include '../../rawcode/menus/customermenu/payofflay-by'; ?></DIV>
<DIV class="mainmenu"><?php include '../../rawcode/menus/mainmenu/mainmenu'; ?></DIV>
<DIV class="topseparator"></DIV>
<DIV class="path">> <A class="gold" href="../../">Payoff lay-by</A> > <A class="gold" href="../accessrecovery">Access recovery</A> > Result</DIV>
<?php echo $result; ?>
<DIV class="bottomseparator"></DIV>
<DIV class="informationmenu"><?php include '../../rawcode/menus/information/information'; ?></DIV>
<DIV class="copyright"><?php include '../../rawcode/menus/copyright/acopyright'; ?></DIV>
</DIV>

Link to comment
Share on other sites

Problem solved:

 

$query = "SELECT * FROM orders WHERE customeremail = '".mysql_real_escape_string($_POST['customere-mail'])."'"; $result = mysql_query($query); mysql_query ($query);
while ($row = mysql_fetch_array($result)) {
echo "LOL";
}
$query = "SELECT * FROM orders WHERE customeremail = '".mysql_real_escape_string($_POST['customere-mail'])."'"; $result = mysql_query($query); $row = mysql_fetch_array($result); mysql_query ($query);
if ($row['customeremail'] != "") {

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.