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 !
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
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
Copy link to clipboard
Copied
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