Jump to content

delamitri

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Contact Methods

  • MSN
    madhatter@delamitri.co.uk
  • ICQ
    12204020

Profile Information

  • Gender
    Not Telling
  • Location
    UK

delamitri's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hmm, entering this into phpmyadmin causes it to fall over. When I type the query below, it does something very strange!! SELECT * FROM reservations WHERE extract(year_month FROM date_departure) = extract(year_month FROM \'2002-12-02\')
  2. easiest way, and i guess that the last poster is right print mysql_error(); after the query call. Kevin
  3. The only way is to use a function to format and unformat the date when reading and writing to a mysql date field. for instance if I had the date from a form as 08.01.2003 (UK style), and wanted to format it to the mysql date type: function format_date($fd_date) { // used to format the date to mysql date $datePart=explode(".", $fd_date); // datePart[0] will be day, [1] will be month, [2] will be year return $datePart[2]."-".$datePart[1]."-".$datePart[0]; } of course you have time in there as well, so may be worth exploding by the space to start with so you get the date, time and AM/PM split into a usable array, then build it up again after you have done the date formatting Just reverse the operation for unformat_date(); Kevin
  4. Its the old problem of making sure your host allows you to connect to the mysql port (3306) remotely. Check with them, if they dont allow it, it can\'t be done! If you have your own server, then you need to open the port to be accessible outside localhost Kevin
  5. You need to set up table permissions. You can restrict read,write, update, delete permissions through phpmyadmin, which really is the best and easiest way of doing this. Also your mysql port needs to be open to access from outside the localhost if you wish to let then access the tables from a webpage not on your server, if your isp will allow this at all! Kevin
  6. Its because of the \', the commas wont affect it. When adding texual data into the database, its a good idea to use addslashes and when retreiving it back out, use stripslashes. so for instance you should use: $query = "INSERT INTO $whattype1 (id, title, description, size, category, bywho, uname, boxurl, urls, type, dateadded) VALUES (\'\', \'".addslashes($title1)."\',\'".addslashes($description1)."\',\'$size1\',\'$category1\',\'$bywho1\',\'$uname1\',\'$boxurl1\',\'$urls1\',\'$type1\',\'$datetime\')"; See http://www.php.net/manual/en/function.addslashes.php for other ways of formatting text for database and urls. Hope this helps Kevin[/code][/url]
  7. Hi all, I have a problem with the YEAR_MONTH query in mysql, which is very bizzarre. Having read the date/time functions on the mysql site, they say using YEAR_MONTH extracts the year an month from a given date field a simple query should work: SELECT YEAR_MONTH(CURDATE()); but get a mysql error. tried SELECT MONTH(CURDATE()) and also SELECT YEAR(CURDATE()) which both work fine, but just cannot use this YEAR_MONTH option. I am using mysql 3.23.47, is this YEAR_MONTH thing not in this version or am I just doing something totally wrong here? BTW even tried replacing CURDATE with NOW() and also a manual input of \'2002-12-22\', but all come up with the same error Kevin
×
×
  • 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.