Jump to content

[SOLVED] Editing echos help


newbtophp

Recommended Posts

Im trying to edit the below code, I tried to make the url open in a new tab, and make the error message go away so their is no error message (if the user does not input the fields and clicks submit it stays on that page until the user does. I dont want the page to redirect to the error message)

 

I've tried inserting code within the echos "..." but I recieve tons of syntax errors, I even tried removing the echos "..." but no luck. :-\

 

Heres the snippet I want to edit:

 

</table>  <td></td><center><b>Sucess! </b><br><br>";
         echo "Your URL: <br>";
         if(isset($t_rows[1])) {
               echo "<input type=\"text\" id=\"Links\"  name\"Links\" value=\"http://www.".$siteurl."/get.php?i=".$folder_id."\" class=\"txt_sucess\" onClick=\"this.form.Links.select();this.form.Links.focus()\">";
            } else {
               echo "<a href="http://www.".$siteurl."/get.php?i=".$folder_id."\">http://".$siteurl."/get.php?i=".$folder_id."</a><br>";
            }
   
      } else {
         echo "<center>Error!";
      }
} else {
?>

 

Can anyone help?

 

Thanks

Link to comment
Share on other sites

Putting your code in the highlighted form will show you the problems:

 

<?php
// some echo up here probably:
echo "
</table>  <td></td><center><b>Sucess! </b><br><br>";
         echo "Your URL: <br>";
         if(isset($t_rows[1])) {
               echo "<input type=\"text\" id=\"Links\"  name\"Links\" value=\"http://www.".$siteurl."/get.php?i=".$folder_id."\" class=\"txt_sucess\" onClick=\"this.form.Links.select();this.form.Links.focus()\">";
            } else {
               echo "<a href="http://www.".$siteurl."/get.php?i=".$folder_id."\">http://".$siteurl."/get.php?i=".$folder_id."</a><br>";
            }
   
      } else {
         echo "<center>Error!";
      }
} else {
?>

 

You need to make sure to escape the quotes, or use single quotes. Here's how I would have done it:

<?php

// some echo up here probably:
echo '
</table>  <td></td><center><b>Sucess! </b><br><br>';
         echo 'Your URL: <br>';
         if(isset($t_rows[1])) {
               echo '<input type="text" id="Links"  name"Links" value="http://www.'.$siteurl.'/get.php?i='.$folder_id.'" class="txt_sucess" onClick="this.form.Links.select();this.form.Links.focus()">';
            } else {
               echo '<a href="http://www.'.$siteurl.'/get.php?i='.$folder_id.'">http://'.$siteurl.'/get.php?i='.$folder_id.'</a><br>';
            }
   
      } else {
         echo '<center>Error!';
      }
} else {
?>

Link to comment
Share on other sites

I did your way by adding an echo above the code and got syntax error after another, nomatter how i modified the code.

 

"Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/something/public_html/api.php on line 93"

Link to comment
Share on other sites

Heres the whole code;

 

<?php
require("config.inc.php");
require("inc/func.php");
$i = 0;
$d = false; //debug
$s = 0;		//success var

if(isset($_POST['submit'])) {
	$id = getNextId();
	$folder = makeClean($_POST['folder']);
	if(isset($_POST['mirror']) && $_POST['mirror']!=""){
		if(is_numeric($_POST['mirror'])) {
			$layerAdsID = $_POST['mirror'];
		} else {
			$mirror = checkURL($_POST['mirror']);
		}
	}
	if(isset($_POST['siteurl']) && $_POST['siteurl']!="") $site_url = checkURL($_POST['siteurl']);
	$admin_pw = makeClean($_POST['adminPW']);

	if(empty($folder)) {
		$folder = createDirName();
		$folder_id = $folder;
	} else {
		$folder_id = createDirName();
	}

	while(folderExists($folder_id)) {
		$folder_id = createDirName();
	}

	$urls 	= array();
	$t_rows = explode("\n", $_POST['urls']);
	foreach($t_rows as $a_rows) {
		if(preg_match ("!^http:\/\/(.*)\.(.*)$!", $a_rows)) {
			$sha1 = sha1($a_rows);
			$md5  = md5($a_rows);
			$time = time();
			$ins = mysql_query("INSERT INTO 
									stealth (
										`url`,
										`sha1`, 
										`md5`, 
										`timestamp`, 
										`visits`, 
										`belongs_to`, 
										`folder_name`,
										`folder_id`,
										`mirror_url`,
										`layeradsid`, 
										`admin_pw`, 
										`website_url`) 
								VALUES (
										'".$a_rows."',
										'".$sha1."',
										'".$md5."',
										'".$time."',
										'0',
										'".$id."',
										'".$folder."',
										'".$folder_id."',
										'".$mirror."',
										'".$layerAdsID."',
										'".$admin_pw."',
										'".$site_url."')
							");

			$i++;
			if($ins) {
				$s = 1;
				if($d) echo "MySQL ".$i." successful! (".mysqlError().").<br>";						
			} else {
				$s = 0;
				if($d) debug("MySQL ".$i." error!", $ins);
			}

		}
	}

	if($s>0) {
		echo "<table border=0 align=center cellpadding=5 cellspacing=5>
  <tr>

  </tr>

</table>  <td></td><center><b>Sucess! </b><br><br>';
         echo 'Your URL: <br>';
         if(isset($t_rows[1])) {
               echo '<input type="text" id="Links"  name"Links" value="http://www.'.$siteurl.'/get.php?i='.$folder_id.'" class="txt_sucess" onClick="this.form.Links.select();this.form.Links.focus()">';
            } else {
               echo '<a href="http://www.'.$siteurl.'/get.php?i='.$folder_id.'">http://'.$siteurl.'/get.php?i='.$folder_id.'</a><br>';
            }
   
      } else {
         echo '<center>Error!';
      }
} else {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <script language="JavaScript" type="text/javascript" src="main.js"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title></title>
    <style type="text/css">
    /*<![CDATA[*/
    div.c1 {text-align: left}
    /*]]>*/
    </style>
</head>
<body>
<div id="sitemain">
  <div id="group">
  <div id="textbox">
    <div class="lr"><div class="ll">

          <div class="tl"><div class="tr"><div class="bl"><div class="br">
            <div class="bod">
                <form action="#" method="post">
        <table border="0" align="center" cellpadding="3" cellspacing="3">
                          <tr>
                            <td><div align="center"><strong>Your Link(s): </strong>
                                  <br />
                                      <textarea name="urls" class="lnkarea"><?=$_POST['urls'];?>
</textarea>
                            </div></td>
                          </tr>
                          <tr>
                            <td><div align="center"><strong>Password: 
                              <br />
                                  <input name="adminPW" type="password" class="form" />
                            </strong></div></td>
                          </tr>
            </table>
					<label>
				<center><input name="submit" type="submit" id="submit" value="Secure!">
		</label>
				<br>
      </form>
<br>
            </div>

<? } ?>

 

Im trying to make the url open in a new tab, and also edit the error echo so it dont exist, when theirs an error the page will stay the same.

Link to comment
Share on other sites

the error is in this section of code

 

<?php
      if($s>0) {
         echo "<table border=0 align=center cellpadding=5 cellspacing=5>
  <tr>

  </tr>

</table>  <td></td><center><b>Sucess! </b><br><br>';
         echo 'Your URL: <br>';
         if(isset($t_rows[1])) {
               echo '<input type="text" id="Links"  name"Links" value="http://www.'.$siteurl.'/get.php?i='.$folder_id.'" class="txt_sucess" onClick="this.form.Links.select();this.form.Links.focus()">';
            } else {
               echo '<a href="http://www.'.$siteurl.'/get.php?i='.$folder_id.'">http://'.$siteurl.'/get.php?i='.$folder_id.'</a><br>';
            }
   
      }

 

if you look at the color coding here (see how useful it is!) you can see that you are trying to echo within another echo which is throwing off all of your quotes

Link to comment
Share on other sites

Change

echo "<table border=0 align=center cellpadding=5 cellspacing=5>
  <tr>

  </tr>

</table>  <td></td><center><b>Sucess! </b><br><br>';

 

To

 

echo '<table border=0 align=center cellpadding=5 cellspacing=5>
  <tr>

  </tr>

</table>  <td></td><center><b>Sucess! </b><br><br>';

Link to comment
Share on other sites

Erm thankss  :-[ But  :o

 

Still can't find how to make the link open in a new tab, and remove the error echo.

 

For the new tab I've tried replacing:

 

echo '<a href="http://www.'.$siteurl.'/get.php?i='.$folder_id.'">http://'.$siteurl.'/get.php?i='.$folder_id.'</a><br>';

 

with

 

echo '<a href="http://www.'.$siteurl.'/get.php?i='.$folder_id.'" target="_blank">http://'.$siteurl.'/get.php?i='.$folder_id.'</a><br>';

 

But that gives syntax errors.

 

For removing error code I've tried replacing (I want to remove the error page so when a incorrect submission is made through the form I dont want it to redirect to the error page, I've tried removing the line but the page still exists but without no text, so I tried the following):

 

echo '<center>Error!';

 

with

 

echo '<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.censored.com/index.php">';

 

Still no luck  :-\ Can anyone provide me the correct code  please ???

 

 

Link to comment
Share on other sites

Your error must be somewhere else as I've tried the exact code:

 

echo '<a href="http://www.'.$siteurl.'/get.php?i='.$folder_id.'" target="_blank">http://'.$siteurl.'/get.php?i='.$folder_id.'</a><br>';

 

and it worked for me.

 

What are the variables set as? Your errors might be stemming from there.

 

Regarding the error message, you're not being redirected to a new page, simply showing a message on the same page which is being confined.

 

Remove the else and brackets as follows,

 

</table>  <td></td><center><b>Sucess! </b><br><br>";
         echo "Your URL: <br>";
         if(isset($t_rows[1])) {
               echo "<input type=\"text\" id=\"Links\"  name\"Links\" value=\"http://www.".$siteurl."/get.php?i=".$folder_id."\" class=\"txt_sucess\" onClick=\"this.form.Links.select();this.form.Links.focus()\">";
            } else {
               echo "<a href="http://www.".$siteurl."/get.php?i=".$folder_id."\">http://".$siteurl."/get.php?i=".$folder_id."</a><br>";
            }
   
      }
} else {
?>

 

You had some additional brackets that I didn't know what went to, so I left them. If you receive any errors, try adding or removing brackets.

 

Link to comment
Share on other sites

LOL This place is awesome, I learn loads.

 

I think I've just answered my own question about the new tab XD

 

However for the removing error mesage, I've already tried that, that only removes the text but not the actual switch between the pages.

 

If I dont fill anything in the form and click submit it goes to that error echo @

 

www.censored.com/#

 

Currently the text which said "Error!" has been removed, but I want the "Error" page to redirect or stay on the homepage.

 

 

Link to comment
Share on other sites

......

If I dont fill anything in the form and click submit it goes to that error echo @

 

www.siteURL.com/#

 

 

um...nice link there....I think u just broke one of the forum rules unintentionally(???)....

.....

Any adult material (18+) is NOT allowed in the forums. If your posts contain links to such material, remove the links before posting.

.....

 

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.