got problem with return and classes[solved]

got problem with return and classes

Page 1 of 1

1 Replies - 392 Views - Last Post: 04 August 2009 - 05:50 PM Rate Topic: -----

#1 huggen  Icon User is offline

  • New D.I.C Head

Reputation: 8
  • View blog
  • Posts: 32
  • Joined: 23-May 09

got problem with return and classes[solved]

Posted 04 August 2009 - 04:50 PM

This donīt work, should echo username and password from my sql database

<?php
	class getsql	{
		function getAccountByName($name)	{
			$databaseusername = "root";
			$databasepassword = "password";
			$database = "database";
			$connect = mysql_connect('localhost', $databaseusername, $databasepassword);
			if (!$connect) {
				die('Could not connect: ' . mysql_error());
			}
			mysql_select_db($database, $connect);
			$result = mysql_query('SELECT * FROM accounts WHERE name = "' . $name . '"');
			$getAccountByName=mysql_fetch_array($result);
			return $getAccountByName;
		}
	}
	
	
	$sql = new getsql;
	$getAccountByName = $sql->getAccountByName("222222");
	echo $getAccountByName;
?>



and it is the return / echo/call that is wrong...some one please help?

donno what happened but now all working....so close and delete

This post has been edited by huggen: 04 August 2009 - 04:59 PM


Is This A Good Question/Topic? 0
  • +

Replies To: got problem with return and classes[solved]

#2 chili5  Icon User is offline

  • D.I.C Lover

Reputation: 20
  • View blog
  • Posts: 1,144
  • Joined: 28-December 07

Re: got problem with return and classes[solved]

Posted 04 August 2009 - 05:50 PM

$sql = new getsql;



Don't you have to use the parenthesis after the class name to ensure you are invoking the constructor?

$sql = new getsql();


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1