• Hi,

    I have a problem while fetching rows from table. Some of my column name(into table) like 1,2,3,4 etc.I used following way to fetch results from database. Code is something like following..

    $results=$wpdb->get_results(“SELECT * FROM mytable”);

    if($wpdb->num_rows)
    {
    foreach ($results as $result)
    {
    echo $result->1; (Not Works)
    echo $result->2; (Not Works)
    echo $result->mycolname; (Works)
    }
    }

    have any solution… thanks a lot.

Viewing 1 replies (of 1 total)
  • Thread Starter dolonmahi

    (@dolonmahi)

    Hi,

    is there any solution?. I think this is the bug into wordpress. I am really disappointed, because i applied it with the simple PHP fetch code and it’s ok. following is the PHP sample code

    <?php
    $results=”SELECT * FROM mytable”;
    $results=mysql_query($results);
    $row=mysql_fetch_array($results);

    if(mysql_num_rows($results))
    {
    while($row=mysql_fetch_assoc($results))
    {
    echo $row[‘1’];/*(Works Fine)*/
    echo $row[‘1’]; /*(Works Fine)*/
    echo $row[‘mycolname’]; /*(Works Fine)*/
    }
    }

    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘$wpdb->get_results() can not fetch row if collunm name is integer’ is closed to new replies.