Results 1 to 5 of 5

Thread: How can I echo $random in this instance?

  1. #1
    Join Date
    Oct 2012
    Posts
    157
    Thanks
    21
    Thanked 1 Time in 1 Post

    Default How can I echo $random in this instance?

    I need to echo $random in $_GET['do'] == but I don't think it's echoing it.

    Code:
    <?php 
     $random = substr(md5(rand()),0,7);
    ?>
    
    
    if ($_GET['do'] == "<?php echo $random ; ?>")


    How would I echo it?
    Last edited by james438; 03-19-2013 at 03:33 PM.

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,998
    Thanks
    16
    Thanked 315 Times in 313 Posts
    Blog Entries
    12

    Default

    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.
    Code:
    <?php 
    $random = substr(md5(rand()),0,7);
    
    if ($_GET['do'] == $something) { 
        echo $random; 
    }?>
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  3. #3
    Join Date
    Oct 2012
    Posts
    157
    Thanks
    21
    Thanked 1 Time in 1 Post

    Default

    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:

    Code:
    <?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']);
    } ?>
    Last edited by james438; 03-19-2013 at 03:33 PM.

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,998
    Thanks
    16
    Thanked 315 Times in 313 Posts
    Blog Entries
    12

    Default

    Oh, in that case, you can just use the $random variable;
    Code:
    if ($_GET['do'] == $random)
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  5. #5
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by qwikad.com View Post
    PHP Code:
    if ($_GET['do'] == ".....I need to echo $random here....."
    Just to clarify, you can not echo anything at that point in your code.

    However, I think Beveryleyh figured out what you actually want to do:
    Quote Originally Posted by Beverleyh View Post
    Oh, in that case, you can just use the $random variable;
    PHP Code:
    if ($_GET['do'] == $random
    correct?

Similar Threads

  1. Replies: 2
    Last Post: 03-17-2013, 04:27 PM
  2. Multiple Instance Issue
    By milindba in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 10-07-2011, 07:40 PM
  3. Multiple instance of Menu
    By Mike3 in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 09-27-2011, 02:36 AM
  4. echo inside an echo?
    By crobinson42 in forum PHP
    Replies: 5
    Last Post: 05-20-2010, 02:32 AM
  5. How to get an object instance ?
    By geemeetheway in forum JavaScript
    Replies: 7
    Last Post: 11-17-2008, 04:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •