-1

Below code shows error

$th= $row['url']; 
//where $row['url']  it contains url///

$get_url = $th; 
$url = trim($get_url);

This is also showing error. How to fix it?

While the below code does not show any error and working fine.

$get_url = $_POST ['url'];
$url = trim($get_url);

The above code which is showing error.
Can any one fix it?

2
  • in your first code $u is not a string use $u = "example.com/xyz.png"; and you don't need $get_url you could directly use $url = trim($u);
    – goupil
    Nov 25, 2015 at 5:46
  • you can also include any errors you get in the question itself. Nov 25, 2015 at 6:06

1 Answer 1

0

In php you need to wrap strings in quotation marks, as well as indicate the end of line with a ;

 $u = "http://example.com/xyz.png";

The reason the code on the bottom doesn't give an error is because php will wrap the result of the POST in quotes by default, as it gets handled like a string.

2
  • $th= $row['url']; ///where it contains url $get_url = $th; $url = trim($get_url); this is also showing error Nov 25, 2015 at 5:55
  • I'm not sure what your question is with the above comment?
    – peanut
    Nov 25, 2015 at 5:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.