![]() |
method madness
ok, i think i've run into a problem but, well here...
Code:
function getone($sql){Code:
$EvSql = " SELECT username FROM users WHERE username ='".$_SESSION['usr_nme']."' ";i get no mysql errors, no log errors, no notices with E_all on.... it returns an empty var... or i think its empty... in that function is $value an array, after returning it at the end? i dont think it should be, not the way i understand things, that should return that 1 cells data out of the db table.... |
mysql_result requires three parameters, the resource, row, and field name.
|
Quote:
|
Quote:
:-) |
Is the result from
$this->query returning the expected result object? Is the return value really "empty", or FALSE (which would be returned when either no usernames match or when mysql_result fails). Use var_dump or some other debugging functions to spot problems rather than relying on error messages being raised to tell you what's wrong.It's difficult to help you with debugging when we just get "help, it doesn't work" style requests. Debug everything, anything possibly related to the problem to make sure things are behaving as you expect (or not behaving!). |
Quote:
And skwee, please don't slander me. |
Quote:
The initial statement is correct, VI said that mysql_result requires three arguments; it doesn't, only requires two arguments with the third field name/offset being optional. I think there may be some confusion over what this function does. The manual should clear that up for anyone not quite clear.However from that point onwards the post strays a little. I'm going to assume that "it" (in "It should return as an array") references the return value of the getone method as that seems most appropriate. It should not be returning an array at all since the method is get one not get array. Since the method will only return FALSE or the row-column value there's no need in this case to use print_r over print as they will behave similarly. That said, in general, functions like print_r and var_dump are useful tools for taking a peek at things. If "it" refers to the local variable within getone there's again no reason to assume that it should be an array, it's likely not to be one if the class architecture is anything resembling useful. If you're talking about mysql_result returning an array, I've no idea where you got that notion.Finally, print can "handle" arrays (in that it doesn't return an error) by doing its job of printing a string representation of the argument (Array).OP, please chime in with some responses. ^^ |
sorry guys i've been down with a migraine for the last few days...
i switched it to print_r in my method, and its working, so far.... though heres something odd i found... the result of a var_dump, on $result breaks the item selected into an array, making $result[1-9] = a letter of that item. aka pulling the username, breaks ths result down, if i print($result) it prints "Evulness" but if i print($result[1]); it returns E, 2 returns v, 3 returns u, etc... if i print $result;, i get the full username.... odd... about how it breaks the username down into an array like that... when i var_dump $result, it gives me Quote:
it looks like its working how i wanted, with it printing the result like that.... see i thought print would work, but print for some odd reason wasn't returning anything, it was in an array, and print($result) was returning result[0], which is empty... but print_r ($result), and print_r($result[0-7]) returned the username, and each letter as it was called... Messing around like that just gave me a good idea for a feature for the cms. thanks for pointing out print_r..... and i never thought of using var_dump.... i have a query output for debugging my mysql, but maybe i should put the var_dump and print_r into it too. |
| All times are GMT. The time now is 04:02 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0