Jump to content


Photo

Help with function parse error


  • Please log in to reply
2 replies to this topic

#1 DataSpy

DataSpy
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 01 September 2006 - 03:41 PM

Hello this is the first time I've ever used a function and was wondering if someone could please help me with a parse error.

<?php
//<!-- mysql connection function -->
function &dbconnection($host, $dbuser, $dbpass, $dbname)
{  
   if (!dbconn = @mysql_connect($host, $dbuser, $dbpass)) {    <=== line 5
   	  return false;
   }
   if (!@mysql_select_db($dbname)) {
   	  return false;
   }
   return $dbconn;
}
//<!-- mysql config -->
$host    = 'localhost';
$dbuser  = 'root';
$dbpass  = '';
$dbname  = 'cms';

$dbconn = &dbconnection($host, $dbuser, $dbpass, $dbname);
?>

The error says:

Parse error: parse error, unexpected '=' in C:\Program Files\xampp\htdocs\www\band\config.php on line 5


Any help would be greatly appretiated, thanx in advance!

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 01 September 2006 - 03:45 PM

This:
if (!dbconn
Should be:
if (!$dbconn

#3 DataSpy

DataSpy
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 01 September 2006 - 04:43 PM

Thanx, sorry for such a stupid mistake, I don't use php that often :( .

Thanx again :) !




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users