Skip to main content
Known Participant
August 26, 2009
解決済み

PHP/MySQL Parse error: syntax error, unexpected T_VARIABLE

  • August 26, 2009
  • 返信数 1.
  • 1612 ビュー

I am new to web programming and I am testing my first PHP/MySQL data request from HTML.

I am already getting the following parsing error:

Parse error: syntax error, unexpected T_VARIABLE......on line 7.

The simple code is as follows:

<? php

    $pwd = $_POST['password'];
    $dbn = $_POST['dbname'];
    $hnm = $_POST['hostname'];

    $link_id = mysql_connect($hnm,$dbn,$pwd);       // this is line 7 where I am getting the error
    if (isset($link_id))
    {
    $result = mysql_list_dbs($link_id);
    echo $result;
    mysql_select_db("hppumps",$link_id);
    $result = mysql_list_tables("hppumps",$link_id);
    echo $result;
    $result = mysql_list_fields("hppumps","models");
    echo $result;
    $rows = mysql_affected_rows($result);
    if ($rows<1) {echo "Error.  The record was not added to the database.";}
    else {echo "$rows record(s) has been added to the database.";}
    }
    else
    {
    echo "Error.  You were unable to connect to the MySql database";
    }
?>

ANY HELP WITH THIS WOULD BE GREATLY APPRECIATED !

このトピックへの返信は締め切られました。
解決に役立った回答 David_Powers

marcusinfla wrote:

<? php

If this is an accurate copy of your code, the problem lies here, and not on line 7.

There should be no space between the question mark and php. The opening PHP tag should look like this:

<?php

返信数 1

David_Powers
David_Powers解決!
Inspiring
August 27, 2009

marcusinfla wrote:

<? php

If this is an accurate copy of your code, the problem lies here, and not on line 7.

There should be no space between the question mark and php. The opening PHP tag should look like this:

<?php

marcusinfla作成者
Known Participant
August 28, 2009

Yes, you are absolutely correct !  I discovered my elementary mistake shortly after I posted the thread.  However, I really do appreciate your response David.  I'm sure I will have more to come.

Marcusinfla