Parse error driving me insane

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Post Reply
johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Parse error driving me insane

Post by johnj » Tue Apr 09, 2013 8:35 pm

Do you need "}" after mysql_close() ??

swarups
New php-forum User
New php-forum User
Posts: 20
Joined: Tue Mar 06, 2012 11:05 pm

Re: Parse error driving me insane

Post by swarups » Tue Apr 09, 2013 9:49 pm

Hi gandy92,

You have missed a curly brace(}) at the end. So the first curly brace({) does not end. Your code should look like

Code: Select all

<?php
if ($_SERVER['REQUEST_METHOD'] == "POST") { 
    $con = mysql_connect("localhost");
    if (!$con){die('Could not connect: ' . mysql_error());} 
    mysql_select_db("site", $con); 
    mysql_query("INSERT INTO contact(email)VALUES ('$_POST[Email]')");
    if ($_POST['submit']){
    
        if ($Email) { 
                echo "Successful";
        }
        
        else {
            echo "ERROR";
        }
    
        mysql_close();
    }//end of 2nd brace
}//end of first brace
?>


I think this will solve your prob. :)

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 973
Joined: Mon Oct 01, 2012 12:32 pm

Re: Parse error driving me insane

Post by seandisanti » Tue Apr 09, 2013 10:01 pm

Also, look into PDO instead of mysql_ functions. mysql_ are deprecated and will probably be removed in a future version sooner rather than later. http://jream.com/learning/videos/php-oo ... o-examples is a good short video of PDO in action. It's faster, more secure, and the accepted standard for database interaction with php. </rant>

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 4 guests