Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: PHP simple blog

  1. #1
    New Coder
    Join Date
    Oct 2013
    Posts
    16
    Thanks
    2
    Thanked 1 Time in 1 Post

    Unhappy PHP simple blog

    I'm trying to create a simple blog and for some reason , it doesnt retrieve the dummy content from the mysql database.
    here is my entire code


    PHP Code:
       <?php  
        $db_host 
    "host"
        
    // Place the username for the MySQL database here 
        
    $db_username "root";  
        
    // Place the password for the MySQL database here 
        
    $db_pass "";  
        
    // Place the name for the MySQL database here 
        
    $db_name "someblog"
        
         
        
    $myConnection mysqli_connect("$db_host","$db_username","$db_pass""$db_name") or die ("could not connect to mysql");  
             
        
    ?> 
        <html>    
            <head>
                <title> Test Blog</title>
            </head>
        <body>
        <?
        $sqlCommand 
    "SELECT title, content, 'date modified ' FROM  blog1tables ORDER BY id DESC"
        
    $query mysqli_query($myConnection$sqlCommand) or die (mysqli_error()); 
        while (
    $row mysqli_fetch_array($query)) { 
           
    $title $row["title"];
        
    $content $row["content"];
        
    $datemodified = ["date modified"];
        }
        
    mysqli_free_result($query); 
         
    ?>
         <table border = '4'>
          <tr><td <? echo $title;?> </td></tr>
          <tr><td colspan="4"> <? echo $content?> </td></tr>
          <tr><td> <? echo $datemodified?> </td></tr>
             
         </table>
         
            
        </body>
        
        </html>

    help

  • #2
    Regular Coder
    Join Date
    Nov 2011
    Posts
    250
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Does it get any of the data from the table?

    Try changing it to this

    PHP Code:
     <?php  
        $db_host 
    "host"
        
    // Place the username for the MySQL database here 
        
    $db_username "root";  
        
    // Place the password for the MySQL database here 
        
    $db_pass "";  
        
    // Place the name for the MySQL database here 
        
    $db_name "someblog"
        
         
        
    $myConnection mysqli_connect("$db_host","$db_username","$db_pass""$db_name") or die ("could not connect to mysql");  
             
        
    ?> 
        <html>    
            <head>
                <title> Test Blog</title>
            </head>
        <body>
        <?
        $sqlCommand 
    "SELECT * FROM  blog1tables ORDER BY id DESC"
        
    $query mysqli_query($myConnection$sqlCommand) or die (mysqli_error()); 
        while (
    $row mysqli_fetch_array($query)) { 
         
        }
        
    mysqli_free_result($query); 
         
    ?>
         <table border = '4'>
          <tr><td <? echo $row['title'];?> </td></tr>
          <tr><td colspan="4"> <? echo $row['content']; ?> </td></tr>
          <tr><td> <? echo $row['date modified']; ?> </td></tr>
             
         </table>
         
            
        </body>
    Last edited by Foster; 10-27-2013 at 09:47 PM.

  • #3
    New Coder
    Join Date
    Nov 2011
    Location
    Ratio, Logic
    Posts
    55
    Thanks
    3
    Thanked 6 Times in 6 Posts
    Try to change colum name to date_modified (and rest of the code related to it).


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •