Jump to content

Recommended Posts

hey im getting an error and i dont seem to know how to fix it, its in the query itself that much i know, i been trying to fix it but nothing is working at the momentthis is the code

function user_data(){$args = func_get_args();$fields = '`' .implode('`, `', $args) . '`';$query = mysql_query("SELECT $fields FROM `users` WHERE `user_id`=".$_SESSION['user_id']);$query_result = mysql_fetch_assoc($query);foreach($args as $fields){  $args[$fields] = $query_result[$fields];}

this is the query im using

$query = mysql_query("SELECT $fields FROM `users` WHERE `user_id`=".$_SESSION['user_id']);

is that query wrong? because i dont seem to be able to get this piece working, anything else i fixed in a few mins, but this is just annoying

Link to comment
Share on other sites

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/content/14/8709614/html/phpalbums/func/user.func.php on line 15since its a mysql_fetch_assoc(); it means the mysql_query is incorrect somewhere along the line, but i dont know whereeeee

Link to comment
Share on other sites

Guest So Called

I've often found queries that failed because the variable data being stuffed into them was wrong or null. My latest practice is to generate every query string before doing the actual access, and save the string in an array of all query strings used in the script. Then when I'm logged in as administrator a final part of my footer generation code echoes all the query strings as HTML comments. I can view source to see the actual data used in queries. (Actually I can also turn this feature on or off. This is of course mature code, and I use the feature when I'm maintaining the site or adding new functionality.) Whenever you have a problem with a query containing variables you should take debug steps to learn exactly how the variable data is being filled into the query. If it's still a problem you can cut and paste the exact query, and run it manually in phpMyAdmin and possibly get new insight and new error indications that show why your query fails.

Link to comment
Share on other sites

this is giving me a dam headache, -_- still isnt working, echoing it out, print_r(), and var_dump(), keep getting bool(false). okie im totally lost on this one hahahahaha

Link to comment
Share on other sites

i did, nothing showed up, and then i did a var_dump and i got a bool(false) its just the query thats not working im going to break it apart to see which part is actually causing a problem

Link to comment
Share on other sites

you are printing the result resource and as it is false, it wont print you anything. you should print the query itself to analize that.

Link to comment
Share on other sites

you are printing the result resource and as it is false, it wont print you anything. you should print the query itself to analize that.
not really im actually printing the query, im getting bool(false) after i add the $_SESSION() function so i have to figure out how to use the session() function within the query to make it work
Link to comment
Share on other sites

there is not any php function like session() or $_SESSION(). can you post your updated code?

Link to comment
Share on other sites

the problem is fixed, it was that the function which allows you to insert the data into the database did not work and still doesnt work, so that have to be fixed

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...