Thread: php problem?

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

    Join Date
    May 2000
    Posts
    24
    Rep Power
    0
    Hi,

    I am having a problem with a php/mysql image
    gallery that I am working on. These 3 lines of code appear to work but everytime the event_id obtained is equal to 2 which is not the case, the event_id variable in the events_gallery table autoincrements starting at 1 but even with 1 entry in the table the event_id obtained using php is 2. The codes is below...

    mysql_query ("INSERT INTO events_gallery VALUES ('$add_event_name', '$img_name', null)");

    $sql = "SELECT ID from events_gallery WHERE (event_name = '$add_event_name')";

    $event_id = mysql_query($sql);

    If i do the same query through telnet I get the correct values using the same SQL statement that im using in php so i have no idea what the problem is... any ideas?
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    24
    Rep Power
    0
    Ok i put that project on hold and went back to another php/mysql thing i was doing (querying a database for event/info) and ran into another differnt but mayb similar problem. I have dates stored in a mysql database of the form yyyy-mm-dd format and im trying to use the date_format function in mysql to convert them then display the result using php. Ive done this using the following code:

    $sql = "select date_format('$temp2','%W %M %D, %Y')";
    $temp = mysql_query($sql);
    print("$temp");

    But once again the commands return the proper results when typing the SQL into telnet but the results are "3:" "4:" etc... when called using the code above. I'm not sure what the problem is. Any help would be apprecaited... thanks in advance!
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Posts
    1
    Rep Power
    0
    ok, cmatrix, i had the same problem and in the meantime you figured it out and helped me that way. i will tell the solution here if anybody else will get into the same problems.
    Use:


    <?php
    $temp2 = "2000-01-04";
    $sql = "select date_format('$temp2','%W %M %D, %Y')";
    $temp = mysql_query($sql);
    $temp_date = mysql_fetch_row($temp);
    echo($temp_date[0]);
    ?>

    credits go to cmatrix, thanx for helping me,
    yves.

IMN logo majestic logo threadwatch logo seochat tools logo