07-13-2008, 09:54 PM
|
#2 (permalink)
|
|
The Acquainted
Join Date: May 2008
Posts: 175
Thanks: 9
|
It is a good start! A few things:
You dont have the class instance variables x and y defined.
Code:
$this->x = $x;
$this->y = $y;
Below your database constant variables, put this
Now your assignments above can actually place these variables, and if you wanted to access what you recently put through the last function call:
PHP Code:
$class = new math;
try { echo $class->plus(22, 55); echo 'We added ' . $class->x . ' + ' . $class->y; } catch(exception $e) { echo $e->getMessage(); }
?>
MysqlI rules, doesn't it? :D
PHP Code:
$db = new mysqli('localhost', 'user', 'pass', 'database'); $query = $db->query("SELECT col1, col2, col3 FROM table WHERE foo = 'bar'");
if ($query->num_rows > 0) { while ($row = $query->fetch_array()) { echo $row['col1'] . ' ' . $row['col2'] . ' ' . $row['col3']; } } else { echo 'no records found'; }
__________________
There are No Stupid Questions. But there a LOT of Inquisitive Idiots.
|
|
|