Jump to content

Query Help


aussiefly

Recommended Posts

Hey everyone!

 

I've got a query that im running to stick multiple values into a table ina  mysql database.

 

$schedule_insert ="INSERT INTO `days` (monday, tuesday, wednesday, thursday, friday, saturday, sunday) VALUES ('$monday','$tuesday','$wednesday','$thursday','$friday','$saturday','$sunday') WHERE userid = $_SESSION[id]";
  $schedule_update = mysql_query($schedule_insert);

 

Now is that the best way to do it and will it work fine??? I've been using the query without the `WHERE` conditional and it works...im just wondering if ive got the WHERE conditional in the right spot.

 

Any ideas

Link to comment
Share on other sites

INSERT is used to create a row in the database, thus I don't think it can be matched with INSERT.

 

You need to use UPDATE as I stated, because the row has already been made (because there is a value for the `userid` already in it).

Link to comment
Share on other sites

yup you guys are totally correct...dont know whay i was trying to insert those details rather than update  :o

 

Anyway, even with update it throws an sql syntax error...this seems to happen when im trying to insert multiple values in my query...anyone know where im going wrong ???

Link to comment
Share on other sites

yup you guys are totally correct...dont know whay i was trying to insert those details rather than update  :o

 

Anyway, even with update it throws an sql syntax error...this seems to happen when im trying to insert multiple values in my query...anyone know where im going wrong ???

 

Try this

 

$schedule_update ="UPDATE `days` SET monday = '" . $monday . "', tuesday = '" . $tuesday . "', wednesday = '" . $wednesday . "', thursday = '" . $thursday. "', friday = '" . $friday . "', saturday = '" . $saturday. "', sunday = '" . $sunday . "' WHERE userid = '" . $_SESSION[id] . "' LIMIT 1";

  

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.