|
Odd php error.. |
Thomas Fjellstrom
Member #476
June 2000
|
Yes, I suck at coming up with topics, so sue me I've been working on two php apps today, and both are giving me the same headache. Some how, php is caching the code and only refreshing when it feels like it. And it doesn't happen all the time, I was making good progress all afternoon till a bout an hour ago... Heres the error I get from php: [Thu Mar 29 18:29:59 2007] [error] [client 192.168.1.20] PHP Fatal error: mysql error: [1146: Table 'moodle.mdl_teachmeto_activeusers' doesn't exist] in EXECUTE("UPDATE mdl_teachmeto_activeusers SET lastactivity = '2007-03-29 18:29:59' WHERE userid = '5'") in /var/www/.../htdocs/lib/adodb/adodb-errorhandler.inc.php on line 77, referer: http://.../chat/ And the funny thing? its right, that table doesn't exist, but it doesn't exist that way in the php code either. grep finds NO references to any mdl_teachmeto_* tables. I'm stuck trying to figure out why php+apache can't seem to notice the code has changed, and hacking with a couple third party apps and libs. All in JS and PHP, neither of which I like very much. -- |
BAF
Member #2,981
December 2002
|
Well, you can specify the DB prefix in moodle, IIRC, so check for teachmeto_ references, as the mdl would be pulled from a configuration. And, unless you have some type of caching setup, it will always execute the PHP every time the page is requested. |
bamccaig
Member #7,536
July 2006
|
Can you tell us anything else? Maybe give us some code? What DBMS are you using? It appears related to ADOdb or the database. Thomas Fjellstrom said: "UPDATE mdl_teachmeto_activeusers SET lastactivity = '2007-03-29 18:29:59' WHERE userid = '5'" Is that your SQL or something from PHP? Should the 5 be in single-quotes...? -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Thomas Fjellstrom
Member #476
June 2000
|
Quote: Well, you can specify the DB prefix in moodle, IIRC, so check for teachmeto_ references, as the mdl would be pulled from a configuration. Ah, the teachmeto stuff is an addition. Its not part of moodle, but it does access some of moodle's dirty bits. Quote: And, unless you have some type of caching setup, it will always execute the PHP every time the page is requested. Good to know. Quote: Can you tell us anything else? Thats all I can think of, it just decides not to notice that some code has changed. Quote: Maybe give us some code? What DBMS are you using? It appears related to ADOdb or the database. Using mysql and ADODB, through moodle's api. Quote: Is that your SQL or something from PHP? Should the 5 be in single-quotes...? Its from php, or possibly moodle's api. -- |
BAF
Member #2,981
December 2002
|
That SQL is fine, as far as the 5 being in quotes goes. |
Thomas Fjellstrom
Member #476
June 2000
|
Lets chock that one up to stupidity (mostly on the part of the original programmer >:E) Now I have another problem that I don't quite get: [Thu Mar 29 20:42:06 2007] [error] [client 192.168.1.20] PHP Catchable fatal error: Object of class stdClass could not be converted to string in /var/www/.../htdocs/chat/chat.php on line 345, referer: http://.../chat/
Quote:
$teachers = array(); ...
-- |
bamccaig
Member #7,536
July 2006
|
BAF said: That SQL is fine, as far as the 5 being in quotes goes. It's like a dynamically typed SQL!? {runs away crying} Are most SQL implementations like that or only MySQL's? -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
BAF
Member #2,981
December 2002
|
That almost sounds like a running-php4-on-php5 or php5-on-php4 type of error. Quote: It's like a dynamically typed SQL!? {runs away crying} If you knew SQL you would know that (IIRC) you are actually supposed to quote everything like that, for security reasons. |
bamccaig
Member #7,536
July 2006
|
I do know SQL and I've never seen that before. In fact, if I'm not mistaken SQL Server will return errors if you quote a numeric field. What security benefit is there to quoting everything? -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
BAF
Member #2,981
December 2002
|
Apparently I am wrong. I'll take note that you are not "supposed" to quote your integral types. As far as I know it works either way, however. |
Thomas Fjellstrom
Member #476
June 2000
|
ok, It may be a php version error, the person that wrote this crap up and ditched on my friend...
From my Very limited knowledge of php, I'd say that looks ok... -- |
bamccaig
Member #7,536
July 2006
|
I looked it up on dev.mysql.com. Apparently MySQL will convert between types when necessary. So if you tried: Result should be: +-----+ | Sum | +-----+ | 2 | +-----+ That's why I ran away crying.......... I don't like that... Dynamic typing is evil... -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
BAF
Member #2,981
December 2002
|
It looks like get_role_users returns an array of classes or something, and array_unique has to be able to convert everything to strings. That's the only possible issue I can see with that code. [edit] |
bamccaig
Member #7,536
July 2006
|
[Reads PHP function] {again runs away crying} -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Thomas Fjellstrom
Member #476
June 2000
|
The problem with trying to var_dump it, is it only works through AJAX its quite hard to get it to pass in some error/debug crap. -- |
BAF
Member #2,981
December 2002
|
Then you could do: file_put_contents('teacher.log', var_export($teachers)); then post teacher.log. |
bamccaig
Member #7,536
July 2006
|
-- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Thomas Fjellstrom
Member #476
June 2000
|
Its empty.. And the get_roles_user functions seem to get the roles in an array of something casted to (object)s. bamccaig: this is not my code, please believe me ;( -- |
bamccaig
Member #7,536
July 2006
|
Thomas Fjellstrom said: And the get_roles_user functions seem to get the roles in an array of something casted to (object)s. The roles of what? -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Thomas Fjellstrom
Member #476
June 2000
|
Quote: The roles of what? Of the user? Like if you're a teacher, or student, or lesbian, etc. edit: actually thats not true... They return other user objects that are assigned to that "role" (in this case, two forms of teacher). -- |
BAF
Member #2,981
December 2002
|
Quote:
Don't ask him, he didn't write it. Nobody really knows what's going on. Quote: Its empty.. And the get_roles_user functions seem to get the roles in an array of something casted to (object)s. How could it be empty and still give those errors? This baffles me. What if you just try return $teachers; dropping the array_unique() call temporarily to see if it at least approaches how it is supposed to work? |
bamccaig
Member #7,536
July 2006
|
BAF said: Don't ask him, he didn't write it. Nobody really knows what's going on. He has more information than I do... I'm just trying to grasp what this function is supposed to do... BAF said: What if you just try return $teachers; dropping the array_unique() call temporarily to see if it at least approaches how it is supposed to work? What if you rewrote the system, just to be sure.....? -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Thomas Fjellstrom
Member #476
June 2000
|
Quote: What if you rewrote the site, just to be sure? I wish, It'll take less time to just find the last bits that are going haywire. -- |
BAF
Member #2,981
December 2002
|
Why rewrite code when you can fix it? The new code won't look much different, and that code at least did something at some point, so it's easier just to fix it, IMO. Anyway, I'm off to bed. I'll post more help in the morning. |
bamccaig
Member #7,536
July 2006
|
BAF said: Why rewrite code when you can fix it? The new code won't look much different, and that code at least did something at some point, so it's easier just to fix it, IMO. Have you ever heard of The Daily WTF, recently renamed Worse Than Failure? Everyday you'll find examples of how the code DIDN'T work at some point (i.e. NEVER worked), and yet it's still part of an enterprise level system... If the guy that wrote that function had a lot to do with the site you might be better off rewriting it from scratch. Patching it to work won't improve maintenance in the future. And I hope that the new code would look much different. {smiley - when will EFW be over with!?!??!?} -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
|
|