php - MySQL Connection to Database -


i have following problem:

i cannot open database connection. can tell me how database-config has if have mysql command?

$dh = new db('table'); $dh->query("select * cars carname '%{$term}%'"); 

i've tried this:

$dh = new db("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass); 

but not work.

so how , have put in host, dbpass , dbuser then?

here complete code:

if(empty($_request['term']))         exit;  $term = $_request['term'];  $dh = new db('table'); $dh->query("select * cars carname '%{$term}%'");  $result = array(); $result['results'] = array(); $result['count'] = 0; while($carname = $dh->fetcharray()){         $result['count']++;         $result['results'][] = $carname; } header('content-type: application/json'); echo json_encode($result); 

i want result json.

but console says:

get http://192.168.50.200:8888/xx/xx/source.php?term=xx 500 (internal server error) 

is because i'm not connected database?

if language php, directly use following:

$connection=mysql_connect("hostname","username","password"); // try using localhost hostname  $db=mysql_select_db("db_name");  $query=mysql_query("select * cars carname '%{$term}%'"); 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -