Log in

View Full Version : How can I echo $random in this instance?



qwikad.com
03-19-2013, 01:14 PM
I need to echo $random in $_GET['do'] == but I don't think it's echoing it.


<?php
$random = substr(md5(rand()),0,7);
?>


if ($_GET['do'] == "<?php echo $random ; ?>")



How would I echo it?

Beverleyh
03-19-2013, 01:25 PM
Youre opening the php again within the echo

Also, I'm not sure what you're matching $_GET['do'] with so for arguments sake, I've matched it to $something.
<?php
$random = substr(md5(rand()),0,7);

if ($_GET['do'] == $something) {
echo $random;
}?>

qwikad.com
03-19-2013, 01:36 PM
I should have said that you should ignore the tags right now. But here's what it actually looks like, and I need to echo the $random right after the == just like it is in the instance below:


<?php
$random = substr(md5(rand()),0,7);
?>

<?php

if ($_GET['do'] == ".....I need to echo $random here.....")
{

if (!$_GET['confirm']) {
ob_clean();
header("Status: 410 Gone");
exit;
}

if (!$is_reported) {


$sql = "UPDATE $adtable
SET abused = abused + 1
WHERE adid = $_GET[adid]
AND abused < " . ($spam_indicator - 1);

mysql_query($sql) or die($sql);

if(mysql_affected_rows())
{
echo "<div class=\"msg\">$lang[MESSAGE_ABUSE_REPORT]</div>";

if($max_abuse_reports)
{

$sql = "UPDATE $adtable
SET enabled = '0'
WHERE adid = $_GET[adid]
AND abused >= $max_abuse_reports";
mysql_query($sql);

}

header("Location: $script_url/?{$qs}reported=y");
exit;
}
}

unset($_GET['do']);
} ?>

Beverleyh
03-19-2013, 02:40 PM
Oh, in that case, you can just use the $random variable;
if ($_GET['do'] == $random)

traq
03-19-2013, 07:26 PM
if ($_GET['do'] == ".....I need to echo $random here.....")
Just to clarify, you can not echo (http://php.net/echo) anything at that point in your code.

However, I think Beveryleyh figured out what you actually want to do:

Oh, in that case, you can just use the $random variable;
if ($_GET['do'] == $random)

correct?