Log in

View Full Version : Blank page because of an echo



naiani
08-31-2007, 02:03 PM
Hi everyone.
I've been having some problems with a PHP implementation here. I have to use a .txt file as a database for the Updates section of this website (http://www.cglg-canada.com/testnew/index_imp.html). I already found a way of doing it, but I still haven't figure out a way of passing the id of the news the user is clicking to the page that is loaded when you click the link More >>.

I thought this was right:

echo "<li><strong>" . $story[1] . "</strong> - " . $story[2] . ". <a href=\"internal/news.php?id=".story[0]."\">More &gt;&gt;</a></li>";
It works perfectly when I don't try to pass the id to the link. But whenever I try to include it, it stops working and gives me a blank page, what I learned that occurs when there's an error in the code. So where is the error? I can't see a reason for it to not work.

-----

EDIT: I forgot to say that I posted the link for the .html page so you can see something similar to what I want to achieve. To see what's happening with the .php, just click the link and then change the extension from .html to .php.

boogyman
08-31-2007, 05:44 PM
i dont see anything wrong per the code that you posted, but do you have access to the error being given?

naiani
08-31-2007, 05:54 PM
I didn't have access to the error. I even tried to check the parsed source code (according to some goggled info, it should contain the error message), but nothing, it was literally a blank page.
But I tried a new approach and it works now. I'm using list() = explode(); to separate the content into distinct vars ($id,$date,$title) and then use these vars in the echo. I don't know why, but apparently this was happening because I was using $story[0] to pass the id to the link in the echo. Why isn't it possible?

boogyman
08-31-2007, 05:55 PM
yes but if there is a blank page then a php error is generated.. i was asking if you had access to the php error log to let us know what the fatal error was.

james438
08-31-2007, 06:04 PM
$data="<li><strong>";
$data .= "$story[1]" ;
$data .= "</strong> - ";
$data .= "$story[2]" ;
$data .= "<a href=\"internal/news.php?id=\"";
$data .= "story[0].\'\'>More &gt;&gt;</a></li>";
echo "$data";

I'm a sloppy coder, but this should work.

EDIT: Actually, I tested it and it worked.

naiani
08-31-2007, 06:28 PM
yes but if there is a blank page then a php error is generated.. i was asking if you had access to the php error log to let us know what the fatal error was.
No, I don't. I don't have access to any kind of "internal" aspects/features of the server.

tech_support
09-01-2007, 02:37 AM
Try adding error_reporting(E_ALL); right under <?php...

alexjewell
09-01-2007, 04:32 PM
And try wrapping your echoed code in single quotes so you don't have to slash the quotes, like so:


echo '<a href="something.html">Sample "quotes"</a>';

It makes the code simple and makes it easier to spot mistakes.

boogyman
09-01-2007, 05:00 PM
And try wrapping your echoed code in single quotes so you don't have to slash the quotes, like so:


echo '<a href="something.html">Sample "quotes"</a>';

It makes the code simple and makes it easier to spot mistakes.

also when you are parsing text you should break out of php as much as possible

alexjewell
09-01-2007, 05:20 PM
Yeah, for example, say if you have an if statement, you could do this and not even use echo:



<?php if(this){ ?>
<!-- HTML HERE -->
<?php } ?>


But we're getting off-subject a bit. :p

JShor
09-01-2007, 07:56 PM
You are repeating your quotes too often...try having your echo a double-quote, and others single quotes....php often gets confusing with characters