Problems with mysql_connect()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm having problems with this code (a simple exercise where i wanto to connect to sql server and get data from it and write that data in html)


:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Exercise 23 - Using PHP with MySQL</title>
</head>

<body>
<?php
	
	//Povezuje se s MySQL serverom
$connection = mysql_connect('localhost','user','pass') or die ("Unable to connect to MySQL server");
	
	//Odabira bazu podataka
	mysql_select_db("php1") or die ("Unable to select database");
	
	//Pravi i zadaje upit
	$query = "SELECT * FROM items";
$result = mysql_query($query) or die ("Error in query: $query ." . mysql_error());
	
	//Provjerava jeli li zapisi vraceni
	if (mysql_num_rows($result) > 0)
	{
		//Pravi html tablicu
		echo "<table width=100% cellpadding=10 cellspacing=0 	 	 	border=1>";
		echo "<tr>
			  	<td>
					<b>ID</b>
				</td>
				<td>
					<b>Name</b>
				</td>
				<td>
					<b>Price</b>
				</td>
			</tr>";
		
		//Prolazi kroz skup zapisa
		//ispisuje svako polje
		while ($row = mysql_fetch_row($result)
		{
			echo "<tr>";
			echo "<td>" . $row [0] ."</td>";
			echo "<td>" . $row [1] ."</td>";
			echo "<td>" . $row [2] ."</td>";
			echo "</tr>";
		}
		echo "</table>";
		
	}
	else
	{
		//Ispisuje poruku o gresci
		echo "No rows found!";
	}
	
	//Kad je obrada gotova oslobada skup rezultata
	mysql_free_result($result);
	
	//Prekida vezu s MySQL serverom
	mysql_close($connection);
?>

</body>
</html>


the error is : "Parse error: parse error, unexpected '{' in C:\Program Files\XAMPP\xampp\htdocs\test_folder\exercise23.php on line 41"

I really dont know why is this error showing i looked for syntax errors but i think that there aren't any


Thanks in advance! :)


(P.S dont read the commnents they are croatian)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux