![]() |
Messing around with OOP
I'm just messing around with OOP since I've never used it before. I'm able to make a connection, select my database, and query it. I'm having a problem when I want to create an array:
mysql.class.php PHP Code:
index.php PHP Code:
Warning: Missing argument 1 for mysql::query(), called in C:\Users\9three\Desktop\Server\htdocs\9three\libra ry\9three\mysql.class.php on line 36 and defined in C:\Users\9three\Desktop\Server\htdocs\9three\libra ry\9three\mysql.class.php on line 25 Fatal error: Uncaught exception 'Exception' with message 'Unable to query' in C:\Users\9three\Desktop\Server\htdocs\9three\libra ry\9three\mysql.class.php:30 Stack trace: #0 C:\Users\9three\Desktop\Server\htdocs\9three\libra ry\9three\mysql.class.php(36): mysql->query() #1 C:\Users\9three\Desktop\Server\htdocs\9three\index 2.php(15): mysql->fetcharray() #2 {main} thrown in C:\Users\9three\Desktop\Server\htdocs\9three\libra ry\9three\mysql.class.php on line 30 I can do it through the procedural but it defeats the purpose of learning :-/ |
Code:
public function fetcharray()$this->fetch = $this->query();). It also tells us that mysql::query() is defined on line 25 (public function query($query)) which clearly accepts one argument.You then get the exception because eventhough you haven't provided the SQL string to mysql::query() it'll still run. Since there's no valid SQL command passed through, mysql_query will do it's job properly allowing you to catch the problem and throw the "Unable to query" exception. So, just remove those parentheses. |
hmm, I'll have to read up on how to properly read errors like those. I did have another problem though, the loop I created doesn't seem to return anything although I already have information in my table.
The loop looks good to me, but obviously I'm doing something wrong. Edit: forgot to mention that yes, that was the problem; The parenthesis shouldn't have been there, thanks. |
| All times are GMT. The time now is 09:18 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0