TinyPortal

Development => Support => Topic started by: Thalov on August 15, 2007, 02:30:23 PM

Title: DB Connection Error
Post by: Thalov on August 15, 2007, 02:30:23 PM
I've written some other php scripts for SMF/TP and they function fine. However for some reason when I did my latest coding when I insert the line of code for connecting to the DB - SMF/TP fails to display anything. What am I doing wrong/what could be causing this?

<link href="http://www.nflcoolertalk.com/USS_Ethos/BioTools/css/bio.css" rel="stylesheet" type="text/css" media="screen" />
<?php
//Initialize and connect to the DB
include('http://www.nflcoolertalk.com/USS_Ethos/SSI.php');
include(
'http://www.nflcoolertalk.com/USS_Ethos/BioTools/account.php');
$user_id $context[user][id];
$table_bio "bio";

$connection = @mysql_connect('$db_host''$db_name''$db_pw') or die(mysql_error());
//$db = @mysql_select_db($db_name, $connection) or die(mysql_error());

//$sql_bio = "SELECT * FROM $table_bio WHERE user = $user_id";
//$result_bio = @mysql_query($sql_bio, $connection) or die(mysql_error());
//$bio = mysql_fetch_array($result_bio);

// Display the various layers
echo "
<div id=\"main\">

<div id=\"header\">
<div id=\"rank\">
$bio[rank]</div>
<div id=\"job2\">
$bio[job2]</div>
<div id=\"name\"><b>
$bio[name]</b></div>
<div id=\"job1\"><b>
$bio[job1]</b></div>
</div>
<div id=\"pic\"></div>
<div id=\"service\">
<div id=\"scontent\">
$bio[service]</div>
</div>
<div id=\"vitals\">
<div id=\"vcontent\">Gender: 
$bio[sex]<br>Species: $bio[species]<br>Height: $bio[h_ft]ft $bio[h_in]in<br>Weight: $bio[weight]lbs<br>Age: $bio[age] years</div>
</div>
<div id=\"medical\">
<div id=\"mcontent\">
$bio[medhistory]</div>
</div>
<div id=\"awards\">
<div id=\"acontent\">
$awards</div>
</div>
<div id=\"backstory\">
<div id=\"bcontent\">
$bio[reveal_background]</div>
</div>
<div id=\"skills\">
<div id=\"skcontent\">
$bio[skills]</div>
</div>
<div id=\"family\">
<div id=\"fcontent\">
$bio[family]</div>
</div>

</div>"
;
?>
Title: Re: DB Connection Error
Post by: IchBin on August 15, 2007, 02:53:09 PM
I think there is no need to surround your connection variables with quotes as that is treating them like strings.
Title: Re: DB Connection Error
Post by: Crip on August 15, 2007, 03:14:01 PM
no need for the direct url path, shorter the better.
Title: Re: DB Connection Error
Post by: Thalov on August 15, 2007, 05:43:55 PM
Yeah - I had originally done it with shorter relative paths and no quotes around the variables. Forgot to change that back when I posted it here.
Title: Re: DB Connection Error
Post by: Thalov on August 15, 2007, 05:46:59 PM
Weird - it magically works. Guess it was just a syntax error somewhere.
Title: Re: DB Connection Error
Post by: Crip on August 15, 2007, 05:49:27 PM
**Stuff** happens