View Full Version : PHP/MySQL Help
Kipkip
November 25th, 2004, 12:04 AM
I'm making a CMS(Content Management System) for my site, and I run into this error:
Warning: Unknown(): Unable to call () - function does not exist in Unknown on line 0
I think the error is kind of funny in a way since there is no line 0. Anyway, I seem to no be able to solve it. Unknown file, weird "I have no idea what that character is" function, and on an unexsisting line.:confused: Can anyone help?
Rukario
November 25th, 2004, 12:44 AM
some more details such as the code in question and/or a link to the page would really help us help you..
Koroku
November 25th, 2004, 01:20 AM
This belongs in Resources...
And as Steve said, the script would be useful. ^_^
Kipkip
November 25th, 2004, 01:23 AM
some more details such as the code in question and/or a link to the page would really help us help you..
I really don't know what part of the code is messed up because of lack of data in the error message. Here's the source code:
<html>
<head>
<title>New News Module</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?php
////////////////////////////////////////////////////////////////////////
//New News Module
//I think...
////////////////////////////////////////////////////////////////////////
require('../includes/dbconnect.php);
// Info varibles
$title = $HTTP_POST_VARS['title'];
$intro = $HTTP_POST_VARS['intro'];
$catergory = $HTTP_POST_VARS['catergory'];
$news = $HTTP_POST_VARS['news'];
//Connection
$connection = new Database();
if ($HTTP_POST_VARS){
$insert = "INSERT INTO news (title,intro,news,catergory) VALUES ('$title', '$intro', '$news', '$catergory')";
if ($result = $connection->db = mysql_query($insert)){
// It worked! You don't suck like the guy below you!
echo 'This piece of news is now added to the database.';
}else{
// You suck. You failed. You'll never be anything.
exit('Sorry, but there was an error when adding this piece of news.<br />');
}
}
?>
<body>
<form name="form1" method="post" action="news.php">
<p> Title:<br />
<input name="title" type="text" id="title">
</p>
<p> Intro:<br />
<input name="intro" type="text" id="intro">
</p>
<p> Catergory:<br />
<select name="catergory" id="catergory">
<?php
$games = $connection->db = mysql_query('SELECT ID,name FROM catergories ORDER BY name');
while ($list = $connection->db = mysql_fetch_array($games)){
echo '<option value="'.$list['ID'].'">'.$list['name'].'</option>';
}
?>
</select>
</p>
<p> Body:<br />
<textarea name="news" cols="50" rows="6" id="news"></textarea>
</p>
<p align="center">
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
Here's the dbconnect file:
<?php
/////////////////////////////////////////////
//Database Connection
/////////////////////////////////////////////
//require('/*Edited out for sercurity measures*/');
class Database extends /*Same as above*/ {
var $Query;
var $db;
function Database(){
$config = /*Same as above two*/::Settings();
$dbhost = $config['dbhost'];
$dbname = $config['dbname'];
$dbuser = $config['dbuser'];
$dbpass = $config['dbpass'];
// Connect to the database
$connect->db = mysql_connect ($dbhost, $dbuser, $dbpass) or die('Could not connect to database for the following reason: ' . mysql_error());
mysql_select_db ($dbname) or die('Could not select database for the following reason: ' . mysql_error());
register_shutdown_function(array(&$connect, 'close'));
}
//Execute Query
function mysql_query($query) {
$connect->Query = $query;
return mysql_query($query, $connect->db);
}
//Get Results
function mysql_fetch_array($result) {
return mysql_fetch_array($result);
}
//Bob: Close connection
//Linda: Closing...
function mysql_close() {
mysql_close($connect->db);
}
}
?>
You can see it here:
http://www.secretgamers.com/CMS/admin/news.php
Works fine. It's just that there is that weird error.
Arcanine
November 25th, 2004, 05:16 PM
Like JK said this goes in Webmasters' Resources.
*Moved*
Kipkip
November 28th, 2004, 01:39 PM
Can anyone help? This is really annoying me. Everything works find, but there's an error. Could it be a problem with the server's PHP?
Geometric-sama
December 1st, 2004, 08:49 AM
I couldn't work it out either - as you know. It's throwing up an error for a function you're not even calling o_O