如果我尝试在我的 CMS 上发布文章,我会收到错误消息。
错误:
警告:mysql_fetch_object():提供的参数不是第 32 行 /home/investmp/domains/cashcow.nl/public_html/publiceer/functions.php 中的有效 MySQL 结果资源您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 'Premiekoopwoning moet terugkomen'、'eddy'、'publiceren')' 附近使用正确的语法
函数.php:
<?php
//## Function list: News Manager ##//
//## Content News: Lead - Header - Chapeaux - Flat text (text) - Quote - Frame - Image - Chart ##//
//Upload images to folder (resize = 1|0 - $dir (default = /images as stated in admin)
function uploadFile($fileinput ,$resize, $dir, $id)
{
global $_FILES;
$file = $_FILES[$fileinput]['name'];
if (is_uploaded_file($_FILES[$fileinput]['tmp_name'])) {
copy($_FILES[$fileinput]['tmp_name'], $dir.$id."_".$file);
if($resize == 1){
imageResize($file);
}
chmod($dir.$id."_".$file, 0775);
return $_FILES[$fileinput]['name'];
}
}
function lastID()
{
$laatsteID = mysql_query("select id from artikelen order by ID DESC limit 1");
$check = mysql_num_rows($laatsteID);
if($check !== 0){
while($lid = mysql_fetch_object($laatsteID)){ $laatsteID = $lid->id; }
} else{
$laatsteID = 0;
}
return $laatsteID;
}
function lastBannerID()
{
include("db_connect.inc.php");
$laatsteID = mysql_query("select id from banners order by id DESC limit 1");
$check = mysql_num_rows($laatsteID);
if($check !== 0){
while($lid = mysql_fetch_object($laatsteID)){ $laatsteID = $lid->id; }
} else {
$laatsteID = 0;
}
return $laatsteID;
}
//Function to change the size of images automatically by default sizes
function imageResize($image, $width)
{
$filename = $image;
//Max height for images (will be downscaled proportionally untill it fits BOTH sizes!)
$height = 200;
header('Content-type: image/jpeg');
list($org_width, $org_height) = getimagesize($filename);
$org_ratio = $org_width/$orig_height;
if($width/$height > $org_ratio){
$width = $height*$org_ratio;
} else {
$height = $width/$org_ratio;
}
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $org_width, $org_height);
}
//Function to add Twitter messages to the Twitter website (through the Newsmanager)
function twitterApi($username,$message)
{
$getUserData = "select twUsername, twPassword from gebruikers where gebruikersnaam = '$username'";
$checkData = mysql_query($getUserData) or die (mysql_error());
while($tweet = mysql_fetch_object($checkData)){
$twusername = $tweet->username;
$twpassword = $tweet->password;
$status = $message;
if ($status) {
$tweetUrl = 'http://www.twitter.com/statuses/update.xml';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "$tweetUrl");
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, "status=$status");
curl_setopt($curl, CURLOPT_USERPWD, "$twusername:$twpassword");
$result = curl_exec($curl);
$resultArray = curl_getinfo($curl);
if ($resultArray['http_code'] == 200)
header("location: ?succes=tweetPosted");
else
header("location: ?error=tweetFailed");
curl_close($curl);
}
}
}
//## User functions ##//
function newUser($gebruikersnaam,$voornaam,$achternaam,$wachtwoord,$gebruikersniveau){
if($wachtwoord !== "" | " " AND $gebruikersnaam !== "" | " "){
$md5wachtwoord = md5($wachtwoord);
require("db_connect.inc.php");
$dubbelegebruiker = mysql_query("select * from gebruikers where gebruikersnaam = '$gebruikersnaam'");
$checkdubbel = mysql_num_rows($dubbelegebruiker);
if($checkdubbel == 0){
$nieuwegebruiker = "insert into gebruikers (gebruikersnaam, voornaam, achternaam, wachtwoord, gebruikersniveau) values ('$gebruikersnaam','$voornaam','$achternaam','$md5wachtwoord','$gebruikersniveau')";
$checkgebruiker = mysql_query($nieuwegebruiker) or die (mysql_error());
header("location: ../index.php?page=gebruikers&succes=userCreated");
} else {
header("location: ../index.php?page=gebruikers&error=failedCreateUser");
}
} else {
header("location: ../index.php?page=gebruikers&error=noUsernamePassword");
}
}
//## Magazine functions ##//
//## Database functions ##//
function eventLog($username, $action)
{
$eventlogger = "insert into systemevents (username, action, date) values ('$username','$action', NOW())";
$checklog = mysql_query($eventlogger) or die (mysql_error());
}
//## Database functions ##//
function insertLog($action, $type, $type_id, $username)
{
if($type == 'banner'){
$selectBanner = mysql_query("select soortbanner, titel from banners where id = '$type_id' limit 1");
while($data = mysql_fetch_object($selectBanner)){
$details = $data->soortbanner;
$titel = $data->titel;
}
} elseif($type == 'bericht') {
$selectBanner = mysql_query("select soortbericht, kop, pubStatus from artikelen where id = '$type_id' limit 1");
while($data = mysql_fetch_object($selectBanner)){
$details = $data->soortbericht;
$titel = $data->kop;
$pubStatus = $data->pubStatus;
}
}
if($type == 'banner' || $type == 'bericht'){
$username = $_SESSION['gebruikersnaam'];
$eventlogger = "insert into systemevents (action, type, type_id, details, titel, username, pubStatus) values ('$action', '$type', '$type_id', '$details', '$titel', '$username', '$pubStatus')";
$checklog = mysql_query($eventlogger) or die (mysql_error());
}
}
function backupDatabase($name,$tables = '*')
{
require("db_connect.inc.php");
//get all of the tables
if($tables == '*')
{
$tables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result))
{
$tables[] = $row[0];
}
}
else
{
$tables = is_array($tables) ? $tables : explode(',',$tables);
}
//cycle through
foreach($tables as $table)
{
$result = mysql_query('SELECT * FROM '.$table);
$num_fields = mysql_num_fields($result);
$return.= 'DROP TABLE '.$table.';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
$return.= "\n\n".$row2[1].";\n\n";
for ($i = 0; $i < $num_fields; $i++)
{
while($row = mysql_fetch_row($result))
{
$return.= 'INSERT INTO '.$table.' VALUES(';
for($j=0; $j<$num_fields; $j++)
{
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
if ($j<($num_fields-1)) { $return.= ','; }
}
$return.= ");\n";
}
}
$return.="\n\n\n";
}
//save file
$handle = fopen('db-backup-'.time().'-'.(md5(implode(',',$tables))).'.sql','w+');
fwrite($handle,$return);
fclose($handle);
header("location: ?succes=backupSucces");
} ?>
有谁能帮忙吗?