0

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?

Edited by Joe34: code

5
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by karthik_ppts
0

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;
1

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.

Votes + Comments
0

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.

This topic has been dead for over six months. 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.