This question already has an answer here:
- How to connect to a SQLite3 db with PHP 3 answers
I need some help with my PHP code. I want to connect to the database file called myChannel.db to extract the data from the rows, but I have got no idea how to do that by using this code:
Here is the config:
<?php
define('DB_HOST', 'localhost');
define('DB_USER', 'myusername');
define('DB_PASSWORD', 'mypassword');
define('DB_DATABASE', 'mydbname');
$errmsg_arr = array();
$errflag = false;
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link)
{
die('Failed to connect to server: ' . mysql_error());
}
$db = mysql_select_db(DB_DATABASE);
if(!$db)
{
die("Unable to select database");
}
?>
Here is the get-listing.php script:
<?php
$errmsg_arr = array();
$errflag = true;
$link;
//Connect to the database
require_once('config.php');
$qrytable1="SELECT id, channels, programme_title, programme_description, programme_start_date, programme_end_date FROM tvguide WHERE channels='$channels' && id='$id'";
$result1 = mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error());
while ($row = mysql_fetch_array($result1))
{
//output the data for channels, programme_title, programme_description, programme_start_date, programme_end
}
?>
The code will only allow me to connect to mysql and nothing is else.
Can you please show me an example how I could connect to myChannel.db and extract the data from the columns called channels, programme_title, programme_description, programme_start_date, programme_end where the channels is matched?
</div>