Thread: Resolved PHP Error
View Single Post
Old 02-07-2013, 05:17 AM   PM User | #1
Jordann
New Coder

 
Join Date: Aug 2012
Location: New Zealand
Posts: 49
Thanks: 2
Thanked 3 Times in 3 Posts
Jordann is an unknown quantity at this point
PHP Error

Im trying to code a events manager off but im coming across this error and unsure how to fix it... Im also new to this whole mysqli thing so if you spot anything out of place feel free to tell me x]

The error im getting is this

Quote:
syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/cookie/public_html/private/clients/planit/includes/post.php on line 61
Heres my code line for line 61

Quote:
mysqli_real_escape_string($_POST['name']),
PHP Code:
<?php      

        $user 
'user';            
    
$db_user 'database';             
    
$db_password 'password';     
    
$db_host 'localhost';   
             
function 
get_ip() {
        if (
$_SERVER['HTTP_X_FORWARD_FOR']) {
            return 
$_SERVER['HTTP_X_FORWARD_FOR'];
        } else {
            return 
$_SERVER['REMOTE_ADDR'];
        }
    }
    
    function 
default_val(&$var$default) {
        if (
$var=='') {
            
$var $default;
        }
    }
    
    function 
check_mail($email) {
        if(
preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/"$email)) {
            list(
$username,$domain)=split('@',$email);
            if(!
checkdnsrr($domain,'MX')) {
                return 
false;
            } else {
                return 
true;
            }
        } else {
            return 
false;
        }
    }
    
if (
$_POST['submit']) {
    
        
$conn new_mysqli($db_hostdb_user$db_password$db_database) or die ('Error connecting to mysql');
        
                   if (
mysqli_connect_errno()) {
   die(
"<font color='red'>Eeeek! Cannot connect user $user, " .
           
" password $password </font>");
}
                
        
            if (
check_mail($_POST['email'])) {
                if (
$_POST['name']) {
                    if (
strstr($_POST['name']," ")) {
                        
$passed true;
                    } else {
                        
$message "Please enter your name.";
                    }
                } else {    
                    
$message "Please enter your name.";
                }
            } else {
                
$message "Please enter a valid email address.";
            }
}
$query "INSERT INTO rsvp (ip, name, email, attend, phone, cell)
VALUES
mysqli_real_escape_string(get_ip()),
mysqli_real_escape_string($_POST['name']),
mysqli_real_escape_string($_POST['email']),
mysqli_real_escape_string($_POST['attend']),
mysqli_real_escape_string($_POST['phone']),
mysqli_real_escape_string($_POST['cell'])"
;
                                       
mysql_query($query);

                    
mysql_close($conn);
?>
Any help is very much appreciated (:

Last edited by Jordann; 02-07-2013 at 09:43 AM..
Jordann is offline   Reply With Quote