Sorry about that.
Here ya go:
Show_Call.php
<?php
$id = $_GET['id'];
$cat = $_GET['cat'];
$database = mysql_connect("localhost", "username", "password");
mysql_select_db("db_name", $database);
$tsql = "SELECT 'Title' FROM '".$cat."' WHERE id='".$id."'";
$Title = mysql_query($tsql, $database);
$Ssql = "SELECT 'Short_Text' FROM '".$cat."' WHERE id='".$id."'";
$Short = mysql_query($Ssql, $database);
$Exql = "SELECT 'Extnd_Text' FROM '".$cat."' WHERE id='".$id."'";
$Ext = mysql_query($Esql, $database);
$dsql = "SELECT 'Date' FROM '".$cat."' WHERE id='".$id."'";
$date = mysql_query($dsql, $database);
function newsTitle(){
global $Title, $database;
if(!$database){
echo('WCVFD - Database Connection Error');
}
else{
echo($Title."\n");
}
}
function bodyText(){
global $Short, $Ext, $database, $tsql, $Ssql, $Title;
if(!$database){
echo('mySQL Database Error!!<br>'.mysql_errno().'<br><br>'.mysql_error().'<br>');
}
else{
$Short = str_replace("\r\n", "<br>", $Short);
$Ext = str_replace("\r\n", "<br>", $Ext);
$Ext = stripslashes($Ext);
$Short = stripslashes($Short);
echo($Short.'<br>'.$Ext);
echo("Title Sql: ".$tsql."<br>");
echo('Short Sql: '.$Ssql);
echo('<br>Title: '.$Title);
}
}
function displayDate(){
global $date, $database;
if(!$database){
echo('Database Error');
}
else{
echo($date);
}
mysql_close();
}
?>
THat is the only file that deals with the database.
My read.php file calls these functions externally.
So..... can anyone see what I'm doing wrong?
EDIT
If you're wondering about my queries and why I don't just define one variable as the query & answer, it's because I've been trying lots of other things to try and solve this. I googled the internet like 100 times before i posted here.
If you know of a better way to do this, let me know.
And yes, my username and password are correct and my user for the database is allowed full access.
EDIT
Here's the error I get after adding a this code:
$Title = mysql_query($tsql, $database) or die(mysql_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 ''call_news' WHERE id='1'' at line 1
PHP version 4.3.8
MySQL version 4.0.20-standard
Thanks for the help.
~Brett