Unable to Search the database using Where clause with string field

I am using following code

public static function getRecord($query){ // Gets single record and returns single associative array
        db::open();
        $result = mysql_query($query) or die(mysql_error());
        if(!mysql_num_rows($result)==0){
            $recordset = mysql_fetch_assoc($result);
            }else{
                $recordset = false;
            }
        db::close();
        return ($recordset);
    }

$query = "SELECT * FROM callDetails WHERE storeName = " . $name ;  

I am getting this error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'E Jewelers LIMIT 0, 50' at line 1

The $name is 'A E Jewelers'

Answers


$query = "SELECT * FROM callDetails WHERE storeName = '" . $name ."'";  

Need Your Help

Elasticsearch, multi_match, ruby on rails

ruby-on-rails elasticsearch

I'm would like to use ElasticSearch to search my collection of products.

PropertyAccessException in Apache camel Spring Ws Configuration

java spring apache-camel apache-httpclient-4.x spring-ws

I want to configure Spring-ws Connection Manager to use PoolingHttpClientConnectionManager. here is my configuration