-5

I am trying to put this line of code:

echo $row['url'];

between the quotations in this line of code:

$data = file_get_contents ("");

I have a link saved in my database which I want to be displayed between those brackets, but I keep getting syntax errors whatever way I try it. Is this possible or am I being stupid?

Logan Wayne
  • 6,001
  • 16
  • 31
  • 49
  • 1
    Probably. You're likely just after `$data = file_get_contents($row['url']);` Hard to tell without you posting your code/errors. – SubjectCurio Jun 20 '14 at 09:24
  • You can interpolate variables inside double-quoted strings in php like this: `$data = file_get_contents("{$row['url']}");`, but if that's the only thing inside those quotes, drop the quotes completely: `$data = file_get_contents($row['url']);` – Oerd Jun 20 '14 at 09:25
  • I'm not getting any syntax errors with those but I'm getting the error 'filename cannot be empty' – user3759532 Jun 20 '14 at 09:29
  • First of all, you told something different in your question. Second, which part of that error message is not clear to you in specific? What do you want to know about it? Why don't you expect the filename to be empty? Why aren't you able to check before opening the file if the filename is empty? Where is your code? Where is your error checking? How do you track errors? – hakre Jun 20 '14 at 09:29
  • I have links saved in a database and echo $row['url']; displays the last link submitted. I'm trying to get that link displayed between the quotations in $data = file_get_contents (""); when I test it the links do display so there is data there, I'm just trying to put it into that line of code. Sorry if I'm not explaining this very well – user3759532 Jun 20 '14 at 09:33

1 Answers1

0

try that :

  $data = file_get_contents ($row['url']);
echo_Me
  • 37,078
  • 5
  • 58
  • 78