I think I must be blind ;)

$Title = $_POST['title'];
    $Category = $_POST['category'];
    $Content = $_POST['article'];
    $Tags = $_POST['tags'];
    $Description = $_POST['description'];

//error below...
    
    $Title = addslashes($Title);

//error above...

    $Category = addslashes($Category);
    $Content = addslashes($Content);
    $Tags = addslashes($Tags);
    $Description = addslashes($Description);

I declared title the first time... $Title = $_POST; ... no problems. Then I declare it again and I get the Undefined variable error. All of the other variables work just fine. What's the problem?

Recommended Answers

All 4 Replies

display the value of $Title before that error line...and make that line as comment and tell whats the error...or whats the output....

echo $Title;

Error is not because of $Title, its because of $_POST.
Write if condition as shown below.

if(isset($_POST['title']))
	$Title = $_POST['title'];

Also you can use error_reporting function to rid of errors.

commented: yes +5

Yes, vibhadevit is right. addslashes only accepts string as an argument, so to make it safe, have a condition to check where the string you supplied to addslashes funtion is not null or something that is not a string.

post your html code too

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.