• Resolved Attila

    (@forexapi)


    Hi Everyone!

    I have a short PHP code which is dosen’t work under WordPress Exec-PHP.

    $day = $_GET[‘day’];
    $date = (string)$day;
    $query = “SELECT * FROM date_”.$date;

    I think the problem is in the first line, but I don’t have any idea what is the solution. The expected result is something this:

    SELECT * FROM date_130131

    Have you any idea?

    Thanks,
    Attila

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can do that all in one line:

    $query = "SELECT * FROM date_".mysql_real_escape_string ($_GET ["day"])

    But… I don’t know if that’s going to get what you want. Do you really have a separate DB table for every day that you are going to query (in your example the table name is ‘date_130131’)? If so that sounds like it’s a really bad way to do it.

    Also, look at what I’ve done, and take a lot of notice of the mysql_real_escape_string() function. You must use this any time you are going to use any SQL query that you are going to run. I cannot stress this enough. without it you are leaving yourself open to SQL injection and risk having your whole DB either compromised or wiped out.

    Thread Starter Attila

    (@forexapi)

    I know it is a strange solution, but my basic problem is the $day = $_GET[‘day’]; have a result if i call the PHP directly in the browser. But if I run the same program in Exec-PHP inside a WordPress based page it has no result. And I don’t know why?

    Thread Starter Attila

    (@forexapi)

    $day = date(ymd);
    $date = (string)$day;
    $query = “SELECT * FROM date_”.$date;

    I found the answer. It was my fault. ??
    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Exec-PHP day reads problem!’ is closed to new replies.