PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello,
Newbie here trying to write a MySQL query and show on screen.
I built the following from what I understood of a tutorial or guide, modified to my site.
As a result, I get a page with no source. I guess that means it crashed.
Help, help, help .... please, and Thank You.
***********
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
if you are using an apache server, go into your program directory/logs and open error.log. Is there an error at the bottom of the file? Also, the echo statements in your while loop should be similar to this:
I'm glad that worked for you. I've never had any luck in getting the \n character to work. I don't know if you have to do something special in order for it to work or not. Can anyone clear that up for us?
guitarlvr wrote:I'm glad that worked for you. I've never had any luck in getting the \n character to work. I don't know if you have to do something special in order for it to work or not. Can anyone clear that up for us?
Wayne
\n is an ascii newline character. It does nothing in HTML, but if you view the textual output, it will place everything after the \n on a new line. It is most commonly found to work on *nix systems. \r is the carriage return character, most commonly found on Macs. \n\r is a combination found in Windows. I think I may have the last two confused, but you get the point.
To test how they work, run this script and view the source:
<?php
$v1 = 'This is the first var... <br />';
$v2 = 'This is the second var... <br />';
$v3 = 'This is the third var... <br />';
$v4 = 'This is the fourth var... <br />';
echo 'This is without newlines in the output....<br /><br />';
echo $v1.$v2.$v3.$v4;
echo 'This is with newlines in the output....<br /><br />';
echo "$v1\n$v2\n$v3\n$v4";
?>
syntax error.
This indicates that the script isn't running with error_reporting=E_ALL and/or display_(startup_)errors=true.
Do you use this php installation for development puurposes only, calvinmicklefinger?
This is without newlines in the output....<br /><br />This is the first var... <br />This is the second var... <br />This is the third var... <br />This is the fourth var... <br />This is with newlines in the output....<br /><br />This is the first var... <br />
This is the second var... <br />
This is the third var... <br />
This is the fourth var... <br />
See how the '\n' wraps the output to the next line? That is what I meant. And be aware those characters only work when wrapped inside double quotes.
Sorry to be slow in responding, I just received the topic notifications this morning.
I will ask my host to help me with error reporting during development.
I am using the host for development until I go live, and since I am such a newbie, I had not thought about turning on error reporting.
Before trying, I think I now understand the difference between the html line brak and the newline. I expect that when I run the sample code, newline will give me a new line in the view source, while the html line break will display items on a new line in the normal browser view. They each depend on the application that is rendering the output.
I expect this newfound knowledge will be very useful in reading source and rendering output.
Might I suggest doing your development locally (on your own computer) then, after testing it on your machine, upload the finished product to your hosted server? Then you don't need to wrestle with your host to get them to do things to their shared servers that they shouldn't be doing anyway.