mysql - Query failed in php -
$query = "select * student student_id = $child , school_id = $college"; $result = mysqli_query($conic, $query); if(!$result){ die(" query failed"); echo 'error here'; } else {
i trying retrieve information sql database query seems fail ideas?
you must learn more : how retrieve data database using select in php
so try out following example display records student table
<?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'rootpassword'; $conn = mysql_connect($dbhost, $dbuser, $dbpass); if(! $conn ) { die('could not connect: ' . mysql_error()); } $sql = "select * student student_id = '"$child"' , school_id = '"$college"' "; mysql_select_db('test_db'); $retval = mysql_query( $sql, $conn ); if(! $retval ) { die('could not data: ' . mysql_error()); } while($row = mysql_fetch_array($retval, mysql_assoc)) { // code here } echo "fetched data successfully\n"; mysql_close($conn); ?>
note
the mysql extension deprecated , removed in future: use mysqli or pdo
Comments
Post a Comment