Getting Null value with JSON from MySQL, how to retrive data from MySQL to JSON correctly?
        Posted  
        
            by sky
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by sky
        
        
        
        Published on 2010-04-19T17:09:17Z
        Indexed on 
            2010/04/19
            17:13 UTC
        
        
        Read the original article
        Hit count: 208
        
I'm using following code but cannot return data from MySQL.
This is the output:
<script type="text/javascript"> 
    var somethings= [null,null,null]; 
</script> 
It does have three post, but I couldn't get the title(message) output.
EDIT: this is the code I'm using:
<?php
    $session = mysql_connect('localhost','name','pass');     
    mysql_select_db('dbname', $session);    
    $result= mysql_query('SELECT * FROM posts', $session); 
    $somethings= array(); 
    while ($row= mysql_fetch_assoc($result)) { 
        $somethings[]= $row['something']; 
    } 
?> 
<script type="text/javascript"> 
    var somethings= <?php echo json_encode($somethings); ?>; 
</script> 
This is the table:
message
Try iPhone post!
Welcome to Yo~ :)
??!
© Stack Overflow or respective owner