Jump to content

blank page appear with this mysqli code


linux1880

Recommended Posts

blank page appear with this mysqli code, pls help

<?php
			// Load in our navigation links from the MySQL database
			require("abc/conn.php");
			$sql = "SELECT * FROM nav";
			$result = $conn->query($sql) or die(mysqli_error());
			if($result){
				while($row = $result->fetch_object()){
					echo "<li><a href='{$row->url}' title='{$row->title}'>{$row->name}</a></li>";					
				}
			}

		?>

Link to comment
Share on other sites

There  May be 2 reasons

1. There is no record for this case check the total number of records

  if(mysqli_num_rows($result)>0){

    echo "zzz";

  }

 

2. There my be connection problem so on error reporting

ini_set("error_reporting", E_ALL);

 

 

Link to comment
Share on other sites

Surprisingly, using the procedural function call mysqli_error() with OOP mysqli just worked when I tried it. However, mysqli_error() requires the $conn variable as a parameter. Otherwise you get a php Warning: and no actual output from mysqli_error that would tell you why the query is failing.

Link to comment
Share on other sites

You need to use mysqli correctly (some of the problems with your mysqli code have been pointed out in the thread.) There is not an exactly 1:1 conversion between mysql and mysqli usage.

 

Yes, the mysqli extension needs to be installed, just like any of the other php language extensions.

 

Are you developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini (when you have access to it), in a local php.ini (when php is running as a CGI application), or using equivalent settings in a .htaccess file (when php is running as an Apache Module) so that php would help you by reporting and displaying all the errors it detects? You will save a TON of time.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.