|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here! |
Share Thread: & Tags
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
$date = ".$year."-".$month."-".$day."";
Would do it assuming you database is using column in date(13) format. Though you did not specify which time format you display to your users on the input form, just re-arrange the vars accordingly. |
|
||||
|
Thanks for the timely reply.
I understand how this will work, but I'm afraid I am unsure of the correct syntax. Where in the PHP document so I insert this statement in order for it to work? Pertinent parts of of my code: Code:
//Connect to db
//Handle form
//Define query
$query1 = "INSERT INTO orders (order_date) VALUES ('{$_POST['order_date']}')";
//Code for month, day, year vars inserted here
<?php $order_date=".$year."-".$month."-".$day."; ?>
|
|
|||
|
You will need to define the date BEFORE the INSERT query
__________________
Hardcore Programming Solutions and Coffee Drinker |
|
|||
|
Code:
/Connect to db //Handle form //define the date $order_date=".$year."-".$month."-".$day."; //Define query $query1 = "INSERT INTO orders (order_date) VALUES ( '$order_date' )"; Code:
$query1 = "INSERT INTO orders (order_date) VALUES ('{$_POST['order_date']}')";
|
|
||||
|
what data type is order_date in the database. Is it just a varchar? or a datetime, bingint, etc.
__________________
www.squitosoft.com - PHP development site. featuring Squito Gallery. a php driven photo gallery. www.rgfx.net - Specializing in Internet solutions, including Html authoring, Interactive Web sites, 3D/2D Graphics and animation. |
|
|||
|
Quote:
If you applied some effort, didnt expect everything done for you and visited the php manual now and again you would learn something. Why not post your code and ask users to write a full working copy of amazon for you. |
|
||||
|
Sorry I ticked you off. I'm really not a total idiot, and I NEVER expect anyone to code for me.
This is my first time using this forum, and I didn't realize that it didn't default to automatically notifying me of new posts. Accordingly, I missed your Tue Aug 31, 2004 6:38 pm post with all of the details in it until I went back to the forum today. You were right - it was easy, and I appreciate your help. |
|
|||
|
No probs.
Most coding is easy its just the knowing how, and the syntaxing. Main thing is you have now learned something. There will be many times when you are stuck, and need a tutorial or manual for something you feel may be very complex. Once you see the answer you wil often look in disbelief at how easy the solution was. |
|
||||
|
Thanks for understanding. This is my first major project working with PHP, and while php.net and a couple of PHP books are at my side constantly, sometimes I think I get too immersed in the learning aspect of it and need to step back for a few minutes and clear my head.
And you're right about the disbelief part. It happened when I implemented your suggestion! |
|
||||
|
What about doing the same thing but using UPDATE in lieu of INSERT?
I have tried using the same syntax and several variations, but have been unsuccessful in making it work. This is one version of what I have attempted: Code:
//Handle date issue $map_eff_date=".$myear."-".$mmonth."-".$mday."; // Define query $query = "UPDATE orders SET map_eff_date='.$myear."-".$mmonth."-".$mday.', LIMIT 1"; Code:
$query = "UPDATE orders SET map_eff_date='$map_eff_date', LIMIT 1"; Code:
$query = "UPDATE orders SET map_eff_date='($map_eff_date)', LIMIT 1"; |
|
|||
|
Take note of the = operator position. Just shft to leave at least one space. A common pitfal.
Also note that you tried to escape and notate at the beginning of your string definition Code:
//Handle date issue $map_eff_date=".$myear."-".$mmonth."-".$mday."; Code:
//Handle date issue $map_eff_date = $myear."-".$mmonth."-".$mday; |
|
||||
|
Thanks! I have corrected the syntax in that line, but I still can't get it to update. All of the other fields will update, but not the date.
Is the problem with the syntax in my UPDATE query? I've checked my book, MySQL manual, and have tried all of the formats listed in my previous post, but nothing seems to work. |
|
|||
|
//Handle date issue
$map_eff_date = $myear."-".$mmonth."-".$mday; $query = ("UPDATE orders SET map_eff_date='$map_eff_date'"); Watch your syntax. Compare the query. Also you do not need to apply any LIMIT on an update. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |