How to resolve "Couldn't execute query"

Discussion in 'Databases' started by yong min kwak, Jan 1, 2014.

  1. Once I confirm to work 'petcatalog.php' in the local development envirnoment, I uploaded database and files to the site.

    Below are the site folders and files
    gosuhdang - site name
    mysql_68691_petcatalog database folder
    petcolor.ibd
    petcolor
    pettype.ibd
    pettype
    etc

    img folder
    petcatalog.php

    Below is a simple script to validate the mySQL connection. It works fine.

    $host = "xxx";
    $user = "xxx";
    $passwd = "xxx";
    $dbname = "mysql_68691_petcatalog";

    <?php
    if (@mysql_connect("host", "user", "passwd")) {
    echo "OK - connected to MySQL";
    } else {
    echo "NOK";
    }
    ?>


    mysqli_connect is OK without "couldn't connect to server".
    $cxn = mysqli_connect($host,$user,$passwd,$dbname)
    or die ("couldn't connect to server");


    However, I got "Couldn't execute query".
    $query = "SELECT * FROM pettype ORDER BY pettype";
    $result = mysqli_query($cxn,$query)
    or die ("Couldn't execute query.");

    Can you help me which ones went wrong??
     

Share This Page