Jump to content

do not understand errors


grabenair

Recommended Posts

I am getting these errors and do not understand why. The code is exactly the way it is in the tut that I am working on and it work fine for them.

 

Warning: array_walk() [function.array-walk]: The argument should be an array in /home/sassy/public_html/cms/core/functions/users.php on line 5

 

Warning: Invalid argument supplied for foreach() in /home/sassy/public_html/cms/core/functions/users.php on line 7

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`user_id` = . 24' at line 1

 

function update_user($update_data){

global $session_user_id;

$update = array();

array_walk($update_data, 'array_sanitize');

 

foreach($update_data as $field=>$data){

$update[] = '`' . $field . '` = \'' . $data . '\'';

}

 

mysql_query("UPDATE `users` SET" . implode(', ', $update) . "WHERE `user_id` = . $session_user_id") or die(mysql_error());

}

Link to comment
Share on other sites

For the array_walk() error, make sure that $update_data is an array. Based on your error, it sounds like $update_data isn't an array. You might use is_array() to double check.

 

I think at least a partial fix of the mysql_query on this line:

 

mysql_query("UPDATE `users` SET" . implode(', ', $update) . "WHERE `user_id` = . $session_user_id") or die(mysql_error());

is this:

 

mysql_query("UPDATE `users` SET " . implode(', ', $update) . " WHERE `user_id` = . $session_user_id") or die(mysql_error());

Note the space after "SET" and before "WHERE".

Link to comment
Share on other sites

This is weird now I am getting this error and was not before.

 

Parse error: syntax error, unexpected '`' in /home/sassy/public_html/cms/core/functions/users.php on line 7

 

Line 7 is this line, right?

 

$update[] = '`' . $field . '` = \'' . $data . '\'';

I'm not having any trouble with that line -- I've tested it on my machine and it works fine for me.

Link to comment
Share on other sites

yes sir also sorry it took so long to get back to you my email is wrong here I need to change it but do not know my password. I just used the default one and my pc crashed so i lost my password file. Also how did you make color syntex it is so much easier to read? If it would help you help this php rookie out I can send you info on how to log in and see all my code in a pm.

Edited by grabenair
Link to comment
Share on other sites

There is a missing password form, which should be fine as long as you know your username. http://www.killersites.com/community/index.php?app=core&module=global&section=lostpass. If that won't work for you for some reason, PM me your new email address and I can change your account.

 

You can add code highlighting by enclosing the code within

 (no spaces -- I had to add a space to make it show up in this post.) You can insert that by clicking the code button in the toolbar when creating a post (it looks like "<>".)

 

Yes, if you PM me the details I can take a look, though I can't obviously guarantee I'll be able to spot the error.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...