0

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("'", "&nbsp;", $title);
	$title = str_replace("`", "&nbsp;", $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("'", "&nbsp;", $body);
	$body = str_replace("`", "&nbsp;", $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!";
/////////////////////////////

?>
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by tomato.pgn
0

have u checked that is there any post data coming???
just echo every variable and check whether it is correct or not...then i can proceed further to help!!!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.