Trying to add table prefix variable to query
| From: | Verdon Vaillancourt | Date: | Tue, 10 Sep 2002 13:05:15 +0000 |
| Subject: | Trying to add table prefix variable to query | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-115845@lists.php.net to get a copy of this message | ||
This query worked until I tried to add support for a table prefix in the
config file. Now it can¹t seem to find the table. Any pointers to what I am
doing wrong?
Thanks, v
Original query:
<?php
...
include("config.php");
$open = mysql_pconnect($hostname,$user,$password);
mysql_select_db("$db",$open);
$result = mysql("$db","SELECT * FROM teams WHERE username =
'admin'");
$i = 0;
$total_rows = mysql_numrows($result);
...
?>
This is my query:
<?php
...
include("config.php");
$open = mysql_pconnect($hostname,$user,$password);
mysql_select_db("$db",$open);
$result = mysql("$db","SELECT * FROM " . $table_prefix . " teams
WHERE username = 'admin'");
$i = 0;
$total_rows = mysql_numrows($result);
...
?>
This is my config file:
<?php
$db = "sports";
$hostname = "localhost";
$password = "mypassword";
$user = "myuser";
$table_prefix = "ccl_";
?>
This is my table name:
ccl_teams
This is the error:
Warning: Supplied argument is not a valid MySQL result resource in...