debugyeh Posted March 21, 2007 Share Posted March 21, 2007 hi everyone, really hope you can help me out, im new to php, and mysql, however, im struggling to get this working, im trying to make the news articles appear with images, however my first problem was getting an image uploaded, i'll worry about getting it to display later. here is my cms-addarticle.php thanks very much in advance <html> <head> <title>Add An Article</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- .box { font-family: Arial, Helvetica, sans-serif; font-size: 12px; border: 1px solid #000000; } --> </style> </head> <body> <?php if(isset($_POST['save'])) { $title = $_POST['title']; $content = $_POST['content']; $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $fp = fopen($tmpName, 'r'); $content1 = fread($fp, $fileSize); $content1 = addslashes($content); fclose($fp); if(!get_magic_quotes_gpc()) { $title = addslashes($title); $content = addslashes($content); $fileName = addslashes($fileName); } include 'library/config.php'; include 'library/opendb.php'; $query = "INSERT INTO news (title, content, name, size, type, content1 ) VALUES ('$title', '$content' '$fileName', '$fileSize', '$fileType', '$content1')"; mysql_query($query) or die('Error ,query failed'); include 'library/closedb.php'; echo "Article '$title' added"; } ?> <form action="" method="post" enctype="multipart/form-data" name="uploadform"> <table width="700" border="0" cellpadding="2" cellspacing="1" class="box" align="center"> <tr> <td width="100">Title</td> <td><input name="title" type="text" class="box" id="title"></td> </tr> <tr> <td width="100">Content</td> <td><textarea name="content" cols="50" rows="10" class="box" id="content"></textarea></td> </tr> <tr> <td width="100"> </td> <td> </td> </tr> <tr> <td colspan="2" align="center"></td> </tr> </table> <table align="center" width="350" border="0" cellpadding="1" cellspacing="1" class="box"> <tr> <td width="246"><input type="hidden" name="MAX_FILE_SIZE" value="2000000"><input name="userfile" type="file" class="box" id="userfile"> </td> <td width="80"><input name="save" type="submit" class="box" id="save" value="Save Article"></td> </tr> </table> </form> </body> </html> i keep getting an error, "error, query failed", which is because the data wont go in the database, but i cant see why. thanks Alan Hamlyn Link to comment https://forums.phpfreaks.com/topic/43662-php-to-mysql-news-system-with-image-content-management-system/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.