Quantcast
Channel: HostGator Peer Support Forums
Viewing all articles
Browse latest Browse all 12024

Issue connecting my database with a php script

$
0
0
Well this has me stumped. I've written a php script but for some reason get no output on my screen when I navigate to the page in my browser.

PHP Code:

<?php

/* Default values
---------------------------------------*/ 

$host "localhost"
$dbms "mysql";
$database = *my_database_name*;
$username = *my_user*;
$password = *password*; 



/* Creating the DSN (Data Source Name)
----------------------------------------*/


$dsn "$dbms:host=$host;dbname=$database";




/* Connecting via PDO
----------------------------------------*/


try{

$dbh = new PDO ($dsn$username$password);


$statement $dbh->prepare("SELECT * FROM sort WHERE sort_id =144 ");
$result $statement->fetchObject();

echo 
$result->movie_title;  




}catch(
PDOException $e) {

    echo 
$e-> getMessage();

    }

?>


Have any of you mre savvy PHP users got any idea where I'm going wrong?

Viewing all articles
Browse latest Browse all 12024

Trending Articles