Failing to query mysql using PHP -
i use form query mysql database in ubuntu server. database connecting somehow results not being echoed requested in code. here sample code
<?php $var=$_request['ip']; echo "$var"; mysql_connect('localhost','root','mysql','syslog') or die("unable connect database"); $result=mysql_query("select * arp_table"); $row=mysql_fetch_row($result); echo $row[0]; ?>
i sure connecting database because not displaying die message, not doing beyond dispaying variable connected form.
according code have provided, parameters have passed mysql_connect wrong.
resource mysql_connect ([ string $server = ini_get("mysql.default_host") [, string $username = ini_get("mysql.default_user") [, string $password = ini_get("mysql.default_password") [, bool $new_link = false [, int $client_flags = 0 ]]]]] )
the 4th parameter new_link not name of database. try following code -
<?php $var = $_request['ip']; echo $var; mysql_connect( "localhost", "root", "mysql" ) or die("unable connect database"); mysql_select_db( "syslog" ); $result = mysql_query( "select * arp_table" ); $row = mysql_fetch_row( $result ); print_r( $row ); ?>
hope helps :)
Comments
Post a Comment