php - Can't get query to show on web page -


working on first mysqli data query. have done ton of reading, not understanding something... or apparently many things

i no errors, blank page. can positive return if use straight php page such example.php, believe connection , basic query can work. in wordpress site.

the results should river fish alsea steelhead applegate fall chinook etc. etc.

i add more columns once basic functionality

<?php $con=mysqli_connect("localhost","database","password","username"); // check connection if (mysqli_connect_errno()) { echo "failed connect mysql: " . mysqli_connect_error(); }  $sql="select river, fish coastal1 order river";  if ($result=mysqli_query($con,$sql)){ // fetch 1 , 1 row while ($row=mysqli_fetch_row($result)){ echo $row[0].'  '.$row[1]; } // free result set mysqli_free_result($result); } ?> 

this line:

$con=mysqli_connect("localhost","database","password","username"); 

"database" goes last

$con=mysqli_connect("localhost","username","password","database"); 

view manual on mysqli_connect():

i.e.:

$con = mysqli_connect("myhost","myuser","mypassw","mybd")          or die("error " . mysqli_error($con)); 

and add or die mysqli_error($con) mysqli_query()


add error reporting top of file(s) find errors.

<?php  error_reporting(e_all); ini_set('display_errors', 1);  // rest of code 

sidenote: error reporting should done in staging, , never production.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -