Mysql PHP won't work -
i have code ill show information database won't work
connecta.php code
<?php $dbhost = '*'; $dbuser = '*'; $dbpass = 'nq4*jh5!'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('could not connect: ' . mysql_error()); } mysql_select_db('*'); mysql_query("set names utf8"); ?>
and source of page have problem
<?php $id = $_request['id']; require("../connecta.php"); $sql = 'select mirror_link fallaga_tbl id=\'$id\' '; $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('could not data: ' . mysql_error()); } ?> <!doctype html> <html> <head> <title>zone-p || fallaga mirror</title> <link rel="stylesheet" type="text/css" href="../home.css"> <link rel="shortcut icon" href="http://www.fallega.tn/icon.gif" height="350" width="350"> </head> <body> <div align="center"> <div class="header"> <div align="center"><a class="titlee" >fallaga mirror</a><br><img width="500px" src="http://tunisiaface.net/wp-content/uploads/2013/04/l.png"></div> <div class="menu"> <ul> <li><a href="../index.php">home</a></li> <li><a href="../news.php">news</a></li> <li><a href="../notify/notify.php">notify</a></li> <li><a href="../notify/massnotify.php">mass notify</a></li> <li><a href="../onhold.php">onhold</a></li> <li><a href="../archive.php">archive</a></li> <li><a href="../about.php">about</a></li> <li><a href="../contact.php">contact</a></li> </ul> </div> </div> <div class="main"> <iframe src=" <?php while($row = mysql_fetch_array($retval, mysql_assoc)) { echo "{$row['mirror_link']}"; } mysql_close($conn) ; ?> " style="width:770px;height:500px;"> <p>your browser not support iframes.</p> </iframe> </div> <div class="bottom"> zone-p - fallaga mirror service © 2014 - <a style="color:white;" href="https://www.facebook.com/mahdi.com.tn ">by màh di</a> </div> </div> </body> </html>
when open page browser see html , no error iframe nothing came in src="" still empty can show me what's wrong ?
it seems should use " instead of ' on line 3, otherwise \'$id\' in sql known string value '$id', not valid id value mysql.
your code on line 3:
$sql = 'select mirror_link fallaga_tbl id=\'$id\' ';
it should be:
$sql = "select mirror_link fallaga_tbl id='{$id}'";
besides can change code line 1 to
$id = mysql_escape_string( $_request['id'] );
to prevent sql injection.
Comments
Post a Comment