php class crash course
Posted
by rabidmachine9
on Stack Overflow
See other posts from Stack Overflow
or by rabidmachine9
Published on 2010-05-19T20:13:56Z
Indexed on
2010/05/19
20:20 UTC
Read the original article
Hit count: 180
Hello people, I'm sorry for this question but I'm getting crazy trying to write my first php clash, it is supposed to connect me to server and to a database but I'm always getting this error:
Parse error: syntax error, unexpected ',', expecting T_PAAMAYIM_NEKUDOTAYIM in /Applications/XAMPP/xamppfiles/htdocs/classTest/test.php on line 9
thanks in advance, here is the code:
<?php
// include 'DBConnect.php';
class DBConnect
{
function connection($hostname = "localhost", $myname = "root", $pass = ''){
mysql_connect(&hostname, &myname, &pass) or die("Could not connect!"); //Connect to mysql
}
function choose($dbnam){
mysql_select_db(&dbnam) or die("Couldn't find database!"); //fnd specific db
}
}
$a = new DBConnect();
$connect = $a->connection("localhost", "root");
$a->choose('mydb');
?>
© Stack Overflow or respective owner