Wednesday 15 July 2015

PHP check if value exists in MySQL -



PHP check if value exists in MySQL -

i tried re-create check if value exists in mysql , create own, reason wont work...

this got:

<?php $host = '127.0.0.1'; $username = 'root'; $password = ''; $dbname = 'multiplayer'; $con=mysqli_connect($host, $username, $password, $dbname); $check_player_ip=mysqli_query($con, 'select `player_ip` `playerdata` username = "remco" , active = 0'); if (mysqli_num_rows($check_player_ip) == 0) { //didnt find } else{ //found } ?>

i error: parse error: syntax error, unexpected '$check_player_ip' (t_variable) in c:\xampp\htdocs\test.php on line 1

solution

if t_variable error, check varriable before rule. may forgot place ';' xd

thanks support!

try this:

<?php $host = '127.0.0.1'; $username = 'root'; $password = ''; $dbname = 'multiplayer'; $con = new mysqli( $host, $username, $password, $dbname ); /* check connection */ if ( $con->connect_error ) { printf( "connect failed: %s\n", $con->connect_error ); exit(); } /* query - returns resultset */ if ( $result = $con->query('select `player_ip` `playerdata` username = "remco" , active = 0 ') ) { if ( $result->num_rows <= 0 ) { //didnt find printf("no player"); } else { //found printf("select returned %d rows.\n", $result->num_rows); } /* free result set */ $result->close(); } /* close connection */ $con->close(); ?>

php mysql

No comments:

Post a Comment