Hey guy, I'm new to php and this forum too... i'm currently working with link shortener scripts, it redirecting using php header function but I don't want to redirect i want to show a banner with original website (like adfly) This is the original code : <?php if($_GET['id']){ require("mysql.php"); // to establish a connection to the db $id = addslashes($_GET['id']); $getUrl = mysql_query("select url from urls where id = $id"); // check if the id exists in the db if(mysql_num_rows($getUrl)==1){ // if so we redirect using the header function $url = mysql_fetch_array($getUrl); header("location:".$url['url']); } else { echo "Error : invalid hash"; } } else { echo "Error : no hash"; }?> PHP: how ever I edited original code and put a iframe to display original website with banner but the thing is it's not working, so please some one can help me with this code, My edited code <html><head> <style type="text/css"><!--body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px;}--></style></head><body><table width="100%" height="10%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFF00"> <tr> <td> </td> </tr></table><?php if($_GET['id']){ require("mysql.php"); // to establish a connection to the db $id = addslashes($_GET['id']); $getUrl = mysql_query("select url from urls where id = $id"); // check if the id exists in the db if(mysql_num_rows($getUrl)==1){ // if so we redirect using the header function $url = mysql_fetch_array($getUrl); $lk= $row[0] ;echo "<iframe src=\"{$lk}\"frameborder=\"0\" height=\"90%\" scrolling=\"auto\" width=\"100%\"></iframe>"; } else { echo "Error : invalid hash"; } } else { echo "Error : no hash"; }?> </body></html> PHP: Hope you can understand what i'm trying to saying and sorry for my bad English ! also guy I really love this script how works and I don't wanna move to a open source thing, just want to edit this code to work as I wish
So when you say it's not working, what is it actually displaying?!? Do you see your banner/logo and the iframe isn't working, or is it all not working? If it's just the iframe, I don't see why you didn't use $url['url']) for the iframe source, and it might be good practice to use concatenation.
ok now I edited code like this (iframe code) echo "<iframe src=\$url['url']\ frameborder=\"0\" height=\"90%\" scrolling=\"auto\" width=\"100%\"></iframe>"; Code (markup): now I can see my banner hanging up there but still iframe is not working,it's getting a error like this
You have to escape the variable or append it. echo "<iframe src=\"{$url['url']}\" frameborder=\"0\" height=\"90%\" scrolling=\"auto\" width=\"100%\"></iframe>"; PHP: or, echo "<iframe src=\"" . $url['url'] . "\" frameborder=\"0\" height=\"90%\" scrolling=\"auto\" width=\"100%\"></iframe>"; PHP: