Azhtek Posted October 21, 2007 Share Posted October 21, 2007 Hi, PHP newb here. (Yes, I figure you're rolling your eyes already) I have a problem with the arcade system I am trying to install on my system, and for me to successfully install it, it requires me to alter a mysql.php and a cfg.php file with my SQL database name, SQL database username and SQL databass password. The cfg.php file is fine, it gives me no problems. The problem is mysql.php. Or so I'm told. The contents of the mysql.php file are: <?php class mysql { var $link; var $querycount=0; var $querylist=''; function connect($host, $username, $password, $db) { $this->link = mysql_connect($host, $username, $password) or die("Could not connect."); mysql_select_db($db) or die("Could not find database."); } function query($query) { if (!($result = mysql_query($query))) { ob_end_clean(); die("SQL Error: ".mysql_error()."<br />Query: $query<br />"); } $this->querycount++; $this->querylist.="<br />$query"; return $result; } function result($result, $row, $name) { return mysql_result($result, $row, $name); } function numrows($result) { $numrows = mysql_num_rows($result); return $numrows; } function affectedrows() { return mysql_affected_rows($this->link); } } ?> Whenever I put in the information into the required fields, I end up with: Parse error: syntax error, unexpected '$', expecting '&' or T_VARIABLE or T_CONST in /home/azhtek1/public_html/Arcade/mysql.php on line 9 Replace those dollar signs with ampersands and I get: Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in /home/azhtek1/public_html/Arcade/mysql.php on line 9 I've asked one or two friends, who are also new to the PHP scene, and they can't see anything wrong with it, except that it's asking for '&' instead of '$'. If anyone has a solution or advice, it would be greatly appreciated. EDIT: And I realise too late now that I posted this in the wrong board... Should be on the mysql help board... Quote Link to comment https://forums.phpfreaks.com/topic/74172-help-a-newb-mysqlphp-dilemma/ Share on other sites More sharing options...
corillo181 Posted October 21, 2007 Share Posted October 21, 2007 you haven't initiated the class if you are using php 4 make a functions with the name of the class function mysql(){ } if you are using php 5 use a construct function __construct(){ } Quote Link to comment https://forums.phpfreaks.com/topic/74172-help-a-newb-mysqlphp-dilemma/#findComment-374581 Share on other sites More sharing options...
Azhtek Posted October 21, 2007 Author Share Posted October 21, 2007 Ah, I see. Thank you. One last question, though: Where would I place that function in mysql.php? Quote Link to comment https://forums.phpfreaks.com/topic/74172-help-a-newb-mysqlphp-dilemma/#findComment-374584 Share on other sites More sharing options...
corillo181 Posted October 21, 2007 Share Posted October 21, 2007 well thats upto you but a well form class would have it right after the class. class thisandthat{ var $that; var $this; // PHP 4 function thisandthat(){ } // PHP 5 function __construct{ } //the rest of the functions after this point } you can also use the construct or the functions name to put in the initial variables. Quote Link to comment https://forums.phpfreaks.com/topic/74172-help-a-newb-mysqlphp-dilemma/#findComment-374587 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.