<?php // Defines PHP connection details define( DBHOST, "", true); define( DBUSER, "", true); define( DBPASS, "", true); define( DBNAME, "", true); public function connect_database() { mysql_connect(DBHOST,DBUSER,DBPASS) or die (mysql_error()); mysql_select_db(DBNAME) or die(mysql_error()); } ?> Code (markup): ok well i cant get this to connect to my database i have all of the write connection details because i can do it normally, but im being retarded and wanting to do this in a function for practise lol. Here is the error im gettin from PHP when the page gets executed. Parse error: parse error, unexpected T_FUNCTION in /home/content/d/e/a/dean5000v/html/oop.php on line 9 if anyone could give me a idea what could be going wrong that would be great
Try This! <?php $dbhost = ""; // Your Host $dbuser = ""; // Your Username $dbpass = ""; // Your Password $dbname = ""; // Your Database Name mysql_connect($dbhost, $dbuser, $dbpass) or die (mysql_error()); mysql_select_db($dbname) or die(mysql_error()); ?> PHP:
yeah i can get it working that way normally easil,y its just writing it into a function which im having trouble with ! thanks for your reply anyways