Jump to content

Recommended Posts

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...

 

Link to comment
https://forums.phpfreaks.com/topic/74172-help-a-newb-mysqlphp-dilemma/
Share on other sites

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.