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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -