1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Help: PHP Line error

Discussion in 'PHP' started by triphp123, Jan 10, 2010.

  1. #1
    Ok this should be simple for an expert.

    I was chnging the urls for the links on a page and now i get error
    Parse error: syntax error, unexpected '<' in /home/sites/orten.me/public_html/sh/createlink.php on line 26
    PHP:
    This is the page in question
    <?php
    /*
    #######################################
    
    
    
    ########################################
    */
    
    include("config.php");
    if (strstr($_SERVER['HTTP_REFERER'], $root));
    else { header ("Location: $rooturl"); }
    
    $ip = $_SERVER['REMOTE_ADDR'];
    $url = mysql_real_escape_string($_POST['url']);
    
    if(preg_match('|^http(s)?://[a-z0-9-]+(\.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url)) {
    	if (empty($_POST['tag'])) {
    		$query = mysql_query("INSERT INTO $table (ip,url) VALUES ('$ip','$url')") or die('MySQL error: '.mysql_error());
    		$qs = mysql_insert_id();
    	} else {
    		if (ereg('^[a-zA-Z0-9]+[a-zA-Z0-9]+$', $_POST['tag'])) {
    			$tag = mysql_real_escape_string($_POST['tag']);
    			$query = mysql_query("select * from $table where `tag` = '$tag';") or die('MySQL error: '.mysql_error());
    			if (mysql_num_rows($query) != 0)
    				die("<p align=\"center\"><font color=\"#FF0000\"><strong>ERROR:</strong></font> The tag you entered has already been taken.<br /> Please <a href =\"javascript:history.back()\">go back</a> and enter a different tag.<br /><br />Powered by <a href=\"http://sh.orten.me\">Sh.orten.Me</a> from <a href=\"http://www.eezyHost.co.uk">eezyHost</a></p>');
    			else {
    				$query = mysql_query("insert $table (ip,url,tag) VALUES ('$ip','$url','$tag')") or die('MySQL error: '.mysql_error());
    				$qs = $tag;
    			}
    		} else
    			die('<p align="center"><font color="#FF0000"><strong>ERROR:</strong></font> Your tag contains invalid characters. Only alphanumeric tags with no spaces are allowed.<br />
    			Please <a href ="javascript:history.back()">go back</a> and enter a different tag.<br /><br />Powered by <a href="http://sh.orten.me">Sh.orten.Me</a> from <a href="http://www.eezyhost.co.uk">eezyHost</a></p>');
    	}
    	$link = $destination . $qs;
    	require 'success.php';
    } else
    	echo '<p align="center"><font color="#FF0000"><strong>ERROR:</strong></font> The URL you entered seems to be invalid.<br />
    			Please <a href ="javascript:history.back()">go back</a> and enter a different tag.<br /><br />Powered by <a href="http://sh.orten.me">Sh.orten.Me</a> from <a href="http://www.eezyhost.co.uk">eezyHost</a></p>';
    
    ?>
    PHP:
    Buggered if I can work it out.

    Anyone please?
     
    triphp123, Jan 10, 2010 IP
  2. astkboy2008

    astkboy2008 Peon

    Messages:
    211
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    lol
    you make it
    if()
    else{
    this is the error i think
    this is the right code
    <?php
    /*
    #######################################
    
    
    
    ########################################
    */
    
    include("config.php");
    if (strstr($_SERVER['HTTP_REFERER'], $root));
    else { header ("Location: $rooturl"); }
    
    $ip = $_SERVER['REMOTE_ADDR'];
    $url = mysql_real_escape_string($_POST['url']);
    
    if(preg_match('|^http(s)?://[a-z0-9-]+(\.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url)) {
        if (empty($_POST['tag'])) {
            $query = mysql_query("INSERT INTO $table (ip,url) VALUES ('$ip','$url')") or die('MySQL error: '.mysql_error());
            $qs = mysql_insert_id();
        } else {
            if (ereg('^[a-zA-Z0-9]+[a-zA-Z0-9]+$', $_POST['tag'])) {
                $tag = mysql_real_escape_string($_POST['tag']);
                $query = mysql_query("select * from $table where `tag` = '$tag';") or die('MySQL error: '.mysql_error());
                if (mysql_num_rows($query) != 0){
                    die("<p align=\"center\"><font color=\"#FF0000\"><strong>ERROR:</strong></font> The tag you entered has already been taken.<br /> Please <a href =\"javascript:history.back()\">go back</a> and enter a different tag.<br /><br />Powered by <a href=\"http://sh.orten.me\">Sh.orten.Me</a> from <a href=\"http://www.eezyHost.co.uk">eezyHost</a></p>');
                }else {
                    $query = mysql_query("insert $table (ip,url,tag) VALUES ('$ip','$url','$tag')") or die('MySQL error: '.mysql_error());
                    $qs = $tag;
                }
            } else
                die('<p align="center"><font color="#FF0000"><strong>ERROR:</strong></font> Your tag contains invalid characters. Only alphanumeric tags with no spaces are allowed.<br />
                Please <a href ="javascript:history.back()">go back</a> and enter a different tag.<br /><br />Powered by <a href="http://sh.orten.me">Sh.orten.Me</a> from <a href="http://www.eezyhost.co.uk">eezyHost</a></p>');
        }
        $link = $destination . $qs;
        require 'success.php';
    } else
        echo '<p align="center"><font color="#FF0000"><strong>ERROR:</strong></font> The URL you entered seems to be invalid.<br />
                Please <a href ="javascript:history.back()">go back</a> and enter a different tag.<br /><br />Powered by <a href="http://sh.orten.me">Sh.orten.Me</a> from <a href="http://www.eezyhost.co.uk">eezyHost</a></p>';
    
    ?>
    PHP:
     
    astkboy2008, Jan 10, 2010 IP
  3. triphp123

    triphp123 Well-Known Member

    Messages:
    1,491
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    125
    #3
    That just results in
     
    triphp123, Jan 10, 2010 IP
  4. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #4
    Try this:

    <?php
    /*
    #######################################
    
    
    
    ########################################
    */
    ob_start();
    include("config.php");
    if (strstr($_SERVER['HTTP_REFERER'], $root)) {
    } else { 
    header ("Location: $rooturl"); 
    }
    
    $ip = $_SERVER['REMOTE_ADDR'];
    $url = mysql_real_escape_string($_POST['url']);
    
    if(preg_match('|^http(s)?://[a-z0-9-]+(\.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $url)) {
        if (empty($_POST['tag'])) {
            $query = mysql_query("INSERT INTO $table (ip,url) VALUES ('$ip','$url')") or die('MySQL error: '.mysql_error());
            $qs = mysql_insert_id();
        } else {
            if (ereg('^[a-zA-Z0-9]+[a-zA-Z0-9]+$', $_POST['tag'])) {
                $tag = mysql_real_escape_string($_POST['tag']);
                $query = mysql_query("select * from $table where `tag` = '$tag';") or die('MySQL error: '.mysql_error());
                if (mysql_num_rows($query) != 0)
                    die("<p align=\"center\"><font color=\"#FF0000\"><strong>ERROR:</strong></font> The tag you entered has already been taken.<br /> Please <a href =\"javascript:history.back()\">go back</a> and enter a different tag.<br /><br />Powered by <a href=\"http://sh.orten.me\">Sh.orten.Me</a> from <a href=\"http://www.eezyHost.co.uk\">eezyHost</a></p>");
                else {
                    $query = mysql_query("insert $table (ip,url,tag) VALUES ('$ip','$url','$tag')") or die('MySQL error: '.mysql_error());
                    $qs = $tag;
                }
            } else
                die('<p align="center"><font color="#FF0000"><strong>ERROR:</strong></font> Your tag contains invalid characters. Only alphanumeric tags with no spaces are allowed.<br />
                Please <a href ="javascript:history.back()">go back</a> and enter a different tag.<br /><br />Powered by <a href="http://sh.orten.me">Sh.orten.Me</a> from <a href="http://www.eezyhost.co.uk">eezyHost</a></p>');
        }
        $link = $destination . $qs;
        require 'success.php';
    } else
        echo '<p align="center"><font color="#FF0000"><strong>ERROR:</strong></font> The URL you entered seems to be invalid.<br />
                Please <a href ="javascript:history.back()">go back</a> and enter a different tag.<br /><br />Powered by <a href="http://sh.orten.me">Sh.orten.Me</a> from <a href="http://www.eezyhost.co.uk">eezyHost</a></p>';
    
    ob_flush();
    ?>
    PHP:
     
    danx10, Jan 10, 2010 IP
  5. triphp123

    triphp123 Well-Known Member

    Messages:
    1,491
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    125
    #5
    That returns
    The fault must be near to the url eezyhost.co.uk as its there abouts that i made changes. The url and texts.
     
    triphp123, Jan 10, 2010 IP
  6. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #6
    Use your original code (from your first post) and....

    Parse error: syntax error, unexpected '<' in /home/sites/orten.me/public_html/sh/createlink.php on line 26
    PHP:
    On line 26:

    die("<p align=\"center\"><font color=\"#FF0000\"><strong>ERROR:</strong></font> The tag you entered has already been taken.<br /> Please <a href =\"javascript:history.back()\">go back</a> and enter a different tag.<br /><br />Powered by <a href=\"http://sh.orten.me\">Sh.orten.Me</a> from <a href=\"http://www.eezyHost.co.uk">eezyHost</a></p>');

    That error is caused by you closing the die() with different quotes, and not escaping the the double quote after co.uk.

    It should be:

     die("<p align=\"center\"><font color=\"#FF0000\"><strong>ERROR:</strong></font> The tag you entered has already been taken.<br /> Please <a href =\"javascript:history.back()\">go back</a> and enter a different tag.<br /><br />Powered by <a href=\"http://sh.orten.me\">Sh.orten.Me</a> from <a href=\"http://www.eezyHost.co.uk\">eezyHost</a></p>");
    PHP:
     
    danx10, Jan 10, 2010 IP
    triphp123 likes this.
  7. triphp123

    triphp123 Well-Known Member

    Messages:
    1,491
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    125
    #7
    Thanks
    Thats done the trick.:D
     
    triphp123, Jan 10, 2010 IP
  8. astkboy2008

    astkboy2008 Peon

    Messages:
    211
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #8
    oh
    "'
    i got it
    you is great triphp123
     
    astkboy2008, Jan 10, 2010 IP