Re: Arrays
| From: | Steve Cayford | Date: | Mon, 15 Apr 2002 20:28:04 +0000 |
| Subject: | Re: Arrays | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-18520@lists.php.net to get a copy of this message | ||
Your $eventdate variable is an array, not a string so you can't just drop it into an sql query string like that.
If you have separate fields in the db for year, month and day then you probably want something like:
$query = "insert into ... values ( ... , '$eventdate[0]', '$eventdate[1]', '$eventdate[2]', ...)";
Otherwise, if they're all supposed to go into the same field then do something like:
$eventdatestring = join("-", $eventdate);
$query = "insert into ... values ( ..., '$eventdatestring', ...)";
This should insert the date in the form "eventyear-eventmonth-eventday";
-Steve
On Monday, April 15, 2002, at 03:13 PM, Alex Francis wrote:
I am trying to insert event dats into a database and to make sure the user puts the date in the correct format. I am now trying to collect the information from the three fields and insert it into one field. code as follows: $eventdate = array ("eventyear", "eventmonth", "eventday"); when I insert it into the database like: $query = "INSERT INTO $tablename4 VALUES ('0', '$entername', '$date', '$eventdate', '$eventheading', '$eventbody' )"; for the $eventdate variable the word "array" is inserted. Could someone please tell me where I am going wrong. -- Alex Francis Cameron Design 35, Drumillan Hill Greenock PA16 0XD Tel 01475 798106 afrancis@camerondesign.co.uk http://www.camerondesign.co.uk This message is sent in confidence for the addressee only. It may contain legally privileged information. Unauthorised recipients are requested to preserve this confidentiality and to advise the sender immediately of any error in transmission. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php