Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I get error "Parse error: syntax error, unexpected T_VARIABLE..

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
full Error as follows:

Parse error: syntax error, unexpected T_VARIABLE in c:\Inetpub\ on line 10

here is my code

Code:
<?php
// Connecting, selecting database
$link = mysqli_connect('localhost:3306', '', 'mysql1', 'test')
   or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('my_database') or die('Could not select database');

// Performing SQL query
$query = 'SELECT * FROM sample'
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
   echo "\t<tr>\n";
   foreach ($line as $col_value) {
       echo "\t\t<td>$col_value</td>\n";
   }
   echo "\t</tr>\n";
}
echo "</table>\n";

// Free resultset
mysql_free_result($result);

// Closing connection
mysql_close($link);
?>

any ideas

DougP, MCP, A+
 
Hello again,

i can't aswear yet but i have found something.

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {

Shouldn't you have used == instead of = ?
= is for assigning values
== is for checking a variables value
=== is @#$% , i know the word only in my language
 
No, it's not that one.
Normally this statement means that there is a missing ";".

This code is the problem.

$query = 'SELECT * FROM sample'

It should be:

$query = 'SELECT * FROM sample';
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top