It wont work, the script might be messed up, please help / give a hint, i'll rep any help.
<?php
session_start();
error_reporting(E_ALL);
//////POST STATEMENTS///////////
$loginid = $_POST['loginid'];
$title = $_POST['title'];
$author = $_POST['author'];
$body = $_POST['body'];
$category = $_POST['category'];
$dbLink = new mysqli('xxxxx.xxxxxx.com', 'xxxxxxx', 'xxxxxxx', 'xxxxxxx');
if(mysqli_connect_errno()) {
die("MySQL connection failed: ". mysqli_connect_error());
}
////////////////////////////////TITLE////////////////////////////////
$title = $_POST['title'];
$title = str_replace("'", " ", $title);
$title = str_replace("`", " ", $title);
$title = nl2br(htmlspecialchars($title));
if (strlen($title)>25)///IF TITLE IS MORE THAN 25
echo "Title can't be more than 25 characters!<br>";
elseif (strlen($title)<3)///IF TITLE IS LESS THAN 3
echo "Title must be more than 3 characters!";
///////////////////////////////BODY////////////////////////////////
$body = $_POST['body'];
$body = str_replace("'", " ", $body);
$body = str_replace("`", " ", $body);
$body = nl2br(htmlspecialchars($body));
if (strlen($body)>10000)
echo "The article contains more than 10 000 characters, please reduce the value.";
elseif (strlen($body)<50)///IF TITLE IS LESS THAN 3
echo "You have to write more than 50 characters.";
function makeClickableLinks($body) {
$body = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '<a href="\\1">\\1</a>', $body);
$body = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', '\\1<a href="http://\\2">\\2</a>', $body);
$body = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})', '<a href="mailto:\\1">\\1</a>', $body);
return $body;
}
$body = makeClickableLinks($body);
//////////////////////////////CATEGORY/////////////////////////////
if(!isset($category))die("Please select a category!");
////////////////////////////////INSERT INTO DB/////////////////////
$userid = $loginid;
$query = "
INSERT INTO `articles` (
`loginid`, `title`, `author`, `body`, `date`, `category`
)
VALUES ('{$userid}',
'{$loginid}', '{$title}', '{$author}', {$body}, {$category}, NOW()";
// Execute the query
$result = $dbLink->query($query);
if($result){
header("location:article.php");
/*$createnew = "./articles/".$title.".html";
$createHandle = fopen($createnew, 'w') or die('Could not create the article, contact for instant help!');
fclose($createHandle);
$fp = fopen($createnew,'a');
$fwrite($fp, '<div class="title">'.$title.'</div><div class="author">'.$author.'</div>'); */
} else echo "The article was not sent, if this problem persist please contact us!";
/////////////////////////////
?>