Jump to content

Recommended Posts

I have been struggling with this sql line for a few days now, and it is really backing this project up.

 

I have php spit out $sql in a die() command, and it looks good.

I also have php tell me how many rows the same line returns when I convert it into a select. 

 

Can someone please help me find the problem with why this simple update does not work.

 

// I left the date command that creates the date and hard coded the date into this example for testing purposes.
$sql = "UPDATE repairs.raitem 
			SET
				repairDate='2010-05-06' AND
				repairTech={$_SESSION['user_id']}
			WHERE
				repairs.raitem.repair IS NOT NULL AND
				repairs.raitem.repairDate IS NULL AND
				repairs.raitem.id={$raitem['id']}
			LIMIT 1"; 

 

ANY help is much appreciated!

 

EDIT:

What I get is repairDate and repairTech are still NULL after the sql is run.  No errors.

Link to comment
https://forums.phpfreaks.com/topic/200909-simple-update-doesnt-work/
Share on other sites

Everyone makes syntax errors, nothing to worry about!

As long as it is solved that is the main thing!

 

I was going to suggest looking at the conditions of the statement though. If you already have a record stored where raitem.id = {$raitem['id']} and it has a date assigned to it already then the statement will not return any records and nothing will be updated.

 

Maybe this is suitable to your application but it just feels a little 'unsafe'

 

Daz

Thanks for the tip.

 

I am using the database to test the condition, not php.  The code I am writing determines the state of a warranty repair.  If the repair field is empty, the repair has not been complete.  I am doing it this way so the user doesn't have to check a checkbox to tell the computer something it can figure out.

 

Is there a better way?

the repair field is the tech's explanation of what he did to fix the engine.

 

We are a small company, about 8 people so I can get away with slack names like that  :P, especially since I'm the only one who knows how to even open the editor for the code.

 

We manufacture model trains...

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.