Thread: PHP Problems

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Cleveland
    Posts
    16
    Rep Power
    0
    Hello!

    I need help in interfacing php with mysql.

    I want to format a date using mysql's date_format function.

    In telnet I typed the following and it works great:
    select DATE_FORMAT('1997-10-04 22:23:00', '%W %M %Y');
    -> 'Saturday October 1997'
    But in php3 I typed the following and it does not work:

    $open_db = MYSQL_CONNECT("localhost","blablabla");
    MYSQL_SELECT_DB("a",$open_db);
    $date_action = select DATE_FORMAT('1997-10-04 22:23:00', '%W %M %Y');
    $date_name = MYSQL_QUERY($date_action,$open_db);
    echo $date_name;

    What is wrong with this code?
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    I'm not sure if it's a typo, but you don't have quotes around your assignment of $date_action:

    $date_action = "select DATE_FORMAT('1997-10-04 22:23:00', '%W %M %Y')";

    Also, after mysql_query(), $date_name would contain the result index, not the result. You still need to extract the data from the results. I.E.:

    $result=mysql_query($date_action);
    list($date_name)=mysql_fetch_row($result);
    echo $date_name;

    HTH

Similar Threads

  1. HELP! PHP - Mime email attachment problems
    By Jbafia in forum PHP Development
    Replies: 7
    Last Post: January 8th, 2005, 02:46 PM
  2. php sessions and security problems.
    By mochico in forum PHP Development
    Replies: 7
    Last Post: February 18th, 2004, 04:51 PM
  3. Email form in PHP was told having problems on a MAC?
    By solcjoye in forum HTML Programming
    Replies: 0
    Last Post: February 12th, 2004, 03:32 PM
  4. problems with php includes
    By boseph in forum PHP Development
    Replies: 9
    Last Post: January 23rd, 2004, 05:27 PM
  5. Problems updating mysql database using Php
    By bassist84 in forum PHP Development
    Replies: 2
    Last Post: January 18th, 2004, 05:26 PM

IMN logo majestic logo threadwatch logo seochat tools logo