Jump to content

mysql_fetch_assoc return null values


Go to solution Solved by benanamen,

Recommended Posts

The code :

<?php 

global $connect;
$connect=  mysqli_connect('localhost', 'root','','andreas');
if (!$connect){
    die('FAILED'. mysqli_error($connect));
 }
                     
                    
                     $the_post_id='46';
                    
                     $query="SELECT * FROM posts WHERE post_id=$the_post_id ";
                     $select_posts_by_id= mysqli_query($connect, $query);
                    
                     while($row= mysqli_fetch_assoc($select_posts_by_id)){
                     
                     
                     $post_title=$_row['post_title'];
                     $post_keimeno=$_row['post_keimeno'];
                     $post_publisher=$_row['post_publisher'];
                     $post_cat_title=$_row['post_cat_title'];
                     $post_image=$_row['post_image'];
                     $post_date= $_row['post_date'];
                     
                     }
   var_dump($the_post_id);   var_dump($select_posts_by_id);  var_dump($row); var_dump($post_title);
                    
                      
        ?>	

The effect below:

 

Notice: Undefined variable: _row in C:\xampp\htdocs\newstheme\admin\includes\test.php on line 18

Notice: Undefined variable: _row in C:\xampp\htdocs\newstheme\admin\includes\test.php on line 19

Notice: Undefined variable: _row in C:\xampp\htdocs\newstheme\admin\includes\test.php on line 20

Notice: Undefined variable: _row in C:\xampp\htdocs\newstheme\admin\includes\test.php on line 21

Notice: Undefined variable: _row in C:\xampp\htdocs\newstheme\admin\includes\test.php on line 22

Notice: Undefined variable: _row in C:\xampp\htdocs\newstheme\admin\includes\test.php on line 23
string(2) "46" object(mysqli_result)#2 (5) { ["current_field"]=> int(0) ["field_count"]=> int( 8) ["lengths"]=> NULL ["num_rows"]=> int(1) ["type"]=> int(0) } NULL NULL

 

What happens?

Thanks a lot.

Link to comment
https://forums.phpfreaks.com/topic/302397-mysql_fetch_assoc-return-null-values/
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.