Hi,
While the script below is working, it's not without some minimal errors. If somebody(s) could help me with this, that would be awesome. Thanks in advance.
Basic overview of the script: It allows the client to add events to their site, and of course edit and delete them.
Here are the problems:
Everytime I add a new event, the code throws in "rnrn" in several places throughout the content. I think it's everytime there's a space.
While I can add html to the content, it doesn't show up for the user. For example, I have link tags surrounding some of the text, but they don't work (I've tested these out on a static page and they work fine). <br> and <strong> tags don't work either.
Any help would be appreciated.
Thanks.
Here's the script (By the way, sorry for adding pretty much the whole thing, I just don't know what parts include/exclude):
<?php
include 'SDFG_Config.php';
function newImage($image, $path, $maxsize, $img_prefix){
$this->path = $path;
$this->image = $image['name'];
$this->maxsize = $maxsize;
$this->image_tmp = $image['tmp_name'];
$this->image_type = $image['type'];
$this->img_prefix = $img_prefix;
$this->image = $this->img_prefix.$this->image;
$this->image = str_replace(" ", "_", $this->image);
$this->allowed = array("image/gif", "image/jpeg", "image/jpg", "image/pjpeg", "image/png");
if(!is_dir($this->path)){
$msg = "Specified path is not a directory. Specified Path = (".$this->path.")";
@unlink($this->image_tmp);
return $msg;
}
if(file_exists($this->path.$this->image)){
@unlink($this->path.$this->image);
}
if(is_uploaded_file($this->image_tmp)){
if(in_array($this->image_type, $this->allowed) !== FALSE){
if($this->image->size > $this->maxsize){
$msg = "File is too big.\n\nMaximum size is: ".$this->maxsize."\n\nYour file was: ".$this->image->size;
unlink($this->image_tmp);
return $msg;
} else {
if(move_uploaded_file($this->image_tmp, $this->path.$this->image)){
$msg = "Image uploaded";
return $msg;
} else {
$msg = "File was not moved from it's temporary location.";
@unlink($this->image_tmp);
return $msg;
}
}
} else {
$msg = "File type \"".$this->image_type."\" is not supported.";
@unlink($this->image_tmp);
return $msg;
}
} else {
$msg = "File was not uploaded to be moved.";
return $msg;
} // end if file is uploaded
}
//end Travis' function
//start main stuff
if(isset($_POST['submit'])){
$title = $_POST['title'];
$dtime = $_POST['dtime'];
$text1 = $_POST['text1'];
$text2 = $_POST['text2'];
$upload = $_POST['upload'];
$newsid = $_POST['newsid'];
//lets verify the data first
if(empty($title)){
echo "Title was empty. Please try again.";
exit;
}
if($_POST['upload'] == "Y"){
$image = $_FILES['image'];
$path = "../images/photos/";
newImage($image, $path, 75000, "");
$sql = "UPDATE news SET image='".$path.$image['name']."'";
if(!mysql_query($sql)){
echo "Error :: The image SQL was not updated!";
}
}
$title = mysql_real_escape_string($title);
$dtime = mysql_real_escape_string($dtime);
$text1 = mysql_real_escape_string($text1);
$text2 = mysql_real_escape_string($text2);
if(get_magic_quotes_gpc()){
$title = stripslashes($title);
$dtime = stripslashes($dtime);
$text1 = stripslashes($text1);
$text2 = stripslashes($text2);
}
$sql = "UPDATE news SET title='".$title."', dtime='".$dtime."', text1='".$text1."', text2='".$text2."' WHERE newsid='".$newsid."'";
if(mysql_query($sql)){
echo '<meta http-equiv="Refresh" content="3;url=SDFG_Index.php">';
echo '<b>Record Updated!</b><br>You\'ll be redirected to the Admin Area in a couple seconds...Hold tight!';
} else {
echo "Error :: The record could not be updated.";
}
} else {
$newsid = $_GET['newsid'];
if(!empty($newsid)){
$sql = mysql_query("SELECT * FROM news WHERE newsid='".$newsid."' LIMIT 0,1");
$fetch = mysql_fetch_array($sql);
extract($fetch);
}
?>