Okay, so I've set up a site to access a (simple) MySQL database of parts, but the devsite is telling me the following error:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\Users\skooter\Dev\Web\trailerParts\scripts\PartsScript.php on line 35
SETUP: WAMP setup, with PHP v5.2.5.
Line 35 (and its surrounds) read:
Code: Select all
<?php
function select($choice) {
/* objects for connection use */
$conn = new DBConnect();
$conf = new DBConfig();
/* select necessary values */
$command = "SELECT * FROM " . $conf->getTableName() . " WHERE category=\"$choice\"";
$this->resource = mysql_query($command, $conn->getResource());
/* check if returned ok */
$this->isFalse();
/* closing connection */
$conn->_destruct();
/* return the resource */
return $this->resource;
}
?>Code: Select all
<?php
class DBConnect {
/* connection resource */
private $res;
function _construct() {
require("./DBConfig.php");
$dbc = new DCConfig();
$this->res = mysql_connect($dbc->getHost(), $dbc->getUser(), $dbc->getPassword());
checkRes();
if (!(mysql_select_db($dbc->getTableName(), $this->res))) {
die("failed to select database: " . error());
}
}
/* returns the connection to the currently connected MySQL resource */
function getResource() {
return $this->res;
}
/* checks if the resource variable has been properly set as a MySQL resource */
function checkRes() {
if (!$this->res) {
die("connection failed: " . error());
}
}
function error() {
return (mysql_errno() . " </br> " . mysql_error());
}
function _destruct() {
include("DBClose.php");
$close = new DBClose();
$close->close($this->res);
}
} // end TPConnect
?>Everah | Please use proper bbCode tags when posting code in the forums. For convenience you can use [code] to highlight code, [php] or [syntax="php"] to highlight PHP or [{lang}] to highlight just about any programming language {lang} (like javascript or vbscript).