php - SQL error: Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource -
i error if try publish article on cms.
the error:
warning: mysql_fetch_object(): supplied argument not valid mysql result resource in /home/investmp/domains/cashcow.nl/public_html/publiceer/functions.php on line 32 have error in sql syntax; check manual corresponds mysql server version right syntax use near 'premiekoopwoning moet terugkomen'', 'eddy', 'publiceren')' @ line 1
functions.php:
<?php //## function list: news manager ##// //## content news: lead - header - chapeaux - flat text (text) - quote - frame - image - chart ##// //upload images folder (resize = 1|0 - $dir (default = /images 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 artikelen order 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 banners order 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 change size of images automatically default sizes function imageresize($image, $width) { $filename = $image; //max height images (will downscaled proportionally untill 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 add twitter messages twitter website (through newsmanager) function twitterapi($username,$message) { $getuserdata = "select twusername, twpassword gebruikers 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 !== "" | " " , $gebruikersnaam !== "" | " "){ $md5wachtwoord = md5($wachtwoord); require("db_connect.inc.php"); $dubbelegebruiker = mysql_query("select * gebruikers gebruikersnaam = '$gebruikersnaam'"); $checkdubbel = mysql_num_rows($dubbelegebruiker); if($checkdubbel == 0){ $nieuwegebruiker = "insert 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 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 banners 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 artikelen 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 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 of 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 $table) { $result = mysql_query('select * '.$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"; ($i = 0; $i < $num_fields; $i++) { while($row = mysql_fetch_row($result)) { $return.= 'insert '.$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"); } ?>
anyone help?
edit these 2 queries in code:
"select twusername, twpassword gebruikers gebruikersnaam = '".$username."'" "select * gebruikers gebruikersnaam = '".$gebruikersnaam."'"
Comments
Post a Comment