Hi everyone, I am getting the following error message on a script page I have.
The error is Parse error: syntax error, unexpected T_IF in blah blah blah on line 432

if($paypal != '') {
            $qry = "SELECT * FROM tbl_name WHERE var='$paypal'";
            $result = mysql_query($qry)
            if($row=mysql_fetch_array($result)) { // this is line 432

            $instcount = getInstanceCount($row['txn_id']);

            if($row["item_name"]=="TlsSingleStore" && $instcount>=1){
                               $msg_error = '<div class="p"><img src="" width="16" height="16"
        hspace="2" vspace="2" align="left" title="Paypal Transaction ID" alt="Paypal Transaction ID" />
        <font color="#FF0000">&nbsp;Paypal Transaction Error</font>&nbsp;Please Check &amp; Try Again</div>
        ';
        $b1=false;
            }elseif($row["item_name"]=="TlsMulitStore" && $instcount>=5){
            $msg_error = '<div class="p"><img src="" width="16" height="16"
        hspace="2" vspace="2" align="left" title="Paypal Transaction ID" alt="Paypal Transaction ID" />
        <font color="#FF0000">&nbsp;Paypal Transaction Error</font>&nbsp;Please Check &amp; Try Again</div>
        ';
            $b1=false;

            }elseif($row["item_name"]=="TlsDeveloperStore" && $instcount>=10){
            $msg_error = '<div class="p"><img src="" width="16" height="16"
        hspace="2" vspace="2" align="left" title="Paypal Transaction ID" alt="Paypal Transaction ID" />
        <font color="#FF0000">&nbsp;Paypal Transaction Error</font>&nbsp;Please Check &amp; Try Again</div>
        ';
            $b1=false;
            }

    }else{
        $msg_error = '<div class="p"><img src="" width="16" height="16"
        hspace="2" vspace="2" align="left" title="Paypal Transaction ID" alt="Paypal Transaction ID" />
        <font color="#FF0000">&nbsp;Paypal Transaction Error</font>&nbsp;Please Check &amp; Try Again</div>
        ';

        $b1=false;
    }
    @mysql_free_result($result);
    }

i have tried adding an additional ")" to the end of line 432, but that does not work, What do I need to do to fix the error and any insight would be appreciated.

Dani AI

Generated

Short answer: is correct — the parse error is caused by a missing statement terminator on the line that executes the query. PHP reports an "unexpected T_IF" on the following line because the parser never saw the previous statement end.

Adding a semicolon to terminate the mysql_query call should fix the immediate parse error. If the error persists, run a quick syntax check with php -l filename.php and enable full error reporting with error_reporting(E_ALL); ini_set('display_errors', 1); to get the exact failure point. Keep in mind PHP's parser often flags the line after the real problem, so also inspect the few lines above the reported line for missing ;, unclosed quotes, parentheses, or braces.

A few practical notes drawn from the posted code: the forum has HTML-encoded operators (&amp;&amp;, &gt;) — in the actual PHP file these must be && and >=. The use of assignment inside if (e.g. if ($row = mysql_fetch_array(...))) is valid but intentional — double-check that an assignment was intended rather than a comparison. Avoid suppressing errors with @ while debugging (the @mysql_free_result($result) call hides useful warnings). Also check the query return before fetching (handle a false return and inspect mysql_error()).

Longer-term: the old mysql_* extension is deprecated and removed in newer PHP versions; migrating to mysqli or PDO with prepared statements improves security and future compatibility.

Member Avatar for Member #120589

You need a ; at the end of this line:

$result = mysql_query($qry)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.