newbtophp Posted May 29, 2009 Share Posted May 29, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/160177-solved-editing-echos-help/ Share on other sites More sharing options...
Philip Posted May 29, 2009 Share Posted May 29, 2009 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 { ?> Quote Link to comment https://forums.phpfreaks.com/topic/160177-solved-editing-echos-help/#findComment-845120 Share on other sites More sharing options...
newbtophp Posted May 29, 2009 Author Share Posted May 29, 2009 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" Quote Link to comment https://forums.phpfreaks.com/topic/160177-solved-editing-echos-help/#findComment-845125 Share on other sites More sharing options...
jsschmitt Posted May 29, 2009 Share Posted May 29, 2009 Can you provide the whole code? This makes it a little difficult to tell what all is going on. Quote Link to comment https://forums.phpfreaks.com/topic/160177-solved-editing-echos-help/#findComment-845127 Share on other sites More sharing options...
newbtophp Posted May 29, 2009 Author Share Posted May 29, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/160177-solved-editing-echos-help/#findComment-845152 Share on other sites More sharing options...
lonewolf217 Posted May 29, 2009 Share Posted May 29, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/160177-solved-editing-echos-help/#findComment-845179 Share on other sites More sharing options...
waynew Posted May 29, 2009 Share Posted May 29, 2009 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>'; Quote Link to comment https://forums.phpfreaks.com/topic/160177-solved-editing-echos-help/#findComment-845181 Share on other sites More sharing options...
newbtophp Posted May 29, 2009 Author Share Posted May 29, 2009 Erm thankss But 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 ??? Quote Link to comment https://forums.phpfreaks.com/topic/160177-solved-editing-echos-help/#findComment-845198 Share on other sites More sharing options...
elis Posted May 29, 2009 Share Posted May 29, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/160177-solved-editing-echos-help/#findComment-845209 Share on other sites More sharing options...
newbtophp Posted May 29, 2009 Author Share Posted May 29, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/160177-solved-editing-echos-help/#findComment-845235 Share on other sites More sharing options...
newbtophp Posted May 30, 2009 Author Share Posted May 30, 2009 Anyone ??? Quote Link to comment https://forums.phpfreaks.com/topic/160177-solved-editing-echos-help/#findComment-845503 Share on other sites More sharing options...
DarkSuperHero Posted May 30, 2009 Share Posted May 30, 2009 ...... 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. ..... Quote Link to comment https://forums.phpfreaks.com/topic/160177-solved-editing-echos-help/#findComment-845542 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.