|
Posted by stiki on 08/26/07 20:53
I can't seem to execute a DDL statement to create a table in my
database.
I'm able to connect to the database, because I tested if connection
was created.
I'm using fnRunSQL($sSQL) (see code below) to run the DDL command and
the function returns false. Does anyone have any idea of what I could
be doing wrong?
$sSQL = "CREATE TABLE upload (
id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30) NOT NULL,
type VARCHAR(30) NOT NULL,
size INT NOT NULL,
path VARCHAR(60) NOT NULL,
PRIMARY KEY(id)
)";
function fnRunSQL($sSQL) {
//Runs a SQL statement and returns
// - TRUE if successful
// - FALSE if it couldn't connect
// - The MySQL error code if the SQL statement fails
global $sDatabaseName, $sUn, $sPw;
if (!$oConn = @mysql_connect($sDatabaseName, $sUn, $sPw)) {
$bRetVal = FALSE;
} else {
if (!mysql_selectdb($sDatabaseName,$oConn)) {
$bRetVal = FALSE;
} else {
if (!$result = mysql_query($sSQL, $oConn)) {
$bRetVal = mysql_error();
dbg("DATABASE ERROR: ".$bRetVal);
} else {
$bRetVal = TRUE;
mysql_free_result($result);
}
}
mysql_close($oConn);
}
return ($bRetVal);
}
Igor
Navigation:
[Reply to this message]
|