Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

PHP/MySQL Parse error: syntax error, unexpected T_VARIABLE

New Here ,
Aug 26, 2009 Aug 26, 2009

Copy link to clipboard

Copied

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 !

TOPICS
Server side applications

Views

1.5K
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 27, 2009 Aug 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

Votes

Translate
LEGEND ,
Aug 27, 2009 Aug 27, 2009

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 27, 2009 Aug 27, 2009

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines