www.webdeveloper.com
Results 1 to 2 of 2

Thread: .php Errors?

  1. #1
    Join Date
    Sep 2012
    Posts
    2

    .php Errors?

    Hi,


    I'm trying to build a "store Bought" guestbook, which is Mysql-.php, with no luck. Would some kind person see if they can spot any errors in the code?
    Thanks,

    Jimmyb
    PHP Code:
    <?php
    // CONNECT TO THE SERVER AND SELECT DATABASE
    $server "ftp.ipage.com";
    $user "*******";
    $password "******";
    $dataBase "tarots.guestbook";

    $conx mysql_connect($server,$user,$password);
    $db_selected mysql_select_db($dataBase,$conx);

    if(
    $conx && $db_selected){
        
    // IF CONNECTION IS ESTABLISHED
        
    $xml "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
        
    $xml .= "<data>\n";
        
        if(isset(
    $_POST['name'])){
            
    $result 0;
            
    $name=mysql_escape_string(trim($_POST['name']));
            
    $email=mysql_escape_string(trim($_POST['email']));
            
    $message=mysql_escape_string(trim($_POST['message']));
            
            
    // ADD DATA TO THE TABLE guestbook WHEN THE USER PRESS THE send_btn in FLASH
            
    $sql="INSERT INTO guestbook(name,email,message,dateAdded)values('$name','$email','$message',now())";
            
    $query mysql_query($sql,$conx);
            if (
    $query){
                
    $result1;
                
    $sql2 "SELECT * FROM guestbook ORDER BY id DESC";
                
    $query2 mysql_query($sql2,$conx);
                
    //WHEN query == true , GET LIST OF MESSAGES  AND PUT THEM AS XML FILE
                
    while($data mysql_fetch_array($query2)){
                    
    $xml .= "<guest>\n";
                    
    $xml .= "<name>".$data['name']."</name>\n";
                    
    $xml .= "<msg><![CDATA[".$data['message']."]]></msg>\n";
                    
    $xml .= "<sdate>".$data['dateAdded']."</sdate>\n";
                    
    $xml .= "</guest>\n";
                    }
                }
            else{
                
    $result=0;
                }
            
    $xml .= "<inserted>".$result."</inserted>\n";
            
        }    
        if(isset(
    $_POST['getMessage'])){
                
    // GET LIST OF MESSAGES AND PUT THEM AS XML FILE
                
    $sql "SELECT * FROM guestbook ORDER BY id DESC";
                
    $query mysql_query($sql,$conx);
                while(
    $data mysql_fetch_array($query)){
                    
    $xml .= "<guest>\n";
                    
    $xml .= "<name>".$data['name']."</name>\n";
                    
    $xml .= "<msg><![CDATA[".$data['message']."]]></msg>\n";
                    
    $xml .= "<sdate>".$data['dateAdded']."</sdate>\n";
                    
    $xml .= "</guest>\n";
                }
            }
        
    $xml .= "</data>\n";
        echo 
    $xml;
    }
    else{
        
    // IF CONNECTION == false OR DATABASE DOESN'T EXISTE
        
    die (mysql_error());
    }
    ?>
    Last edited by NogDog; 03-29-2014 at 05:20 PM. Reason: added [php] tags around code

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,175
    I don't see any parse errors, so try adding this at the top for now:
    PHP Code:
    <?php
    ini_set
    ('display_errors'true);
    error_reporting(E_ALL);
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles