Results 1 to 8 of 8

Thread: Php

  1. #1
    lazy student nvening's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    4,656
    Thanks
    196
    Thanked
    31 times in 30 posts

    Php

    Im going through a PHP tutorial and about halfway through it starts using \n all over the place without any explanation - What does this do?

    Google didnt help as it justs searches for the n lol

    Thanks!
    (\__/)
    (='.'=)
    (")_(")

  2. #2
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS
    "\n" is a unix escape code meaning "new line"

    see also: \t for tab, \\ for backslash, and so on

  3. #3
    lazy student nvening's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    4,656
    Thanks
    196
    Thanked
    31 times in 30 posts
    Ok - i think i under stand that - however i have come up with another problem:

    I have been given code to make a table - as far as i can tell its the same as i am copying from but it will not work

    Code:
    <html>
    <head>
    <title>Table Example</title>
    </head>
    <body>
    <table border=1 bgcolor=yellow>
    
    <?php
    
    $AcmeCars = array ("Ford", "Dodge", "Chevy");
    $AcmeCarId = array ("K234", "J987", "F982");
    
    for ($×=0; $× < count ($AcmeCars); $×++) {
    print "<tr><td>$AcmeCarId[$×]</td>";
    print"<td>$Acme Cars[$×]</td></tr>\n";
    }
    
    ?>
    
    </table>
    </body>
    </html>
    Can anyone see the problem?

    Thanks
    (\__/)
    (='.'=)
    (")_(")

  4. #4
    Flak Monkey! Dorza's Avatar
    Join Date
    Jul 2003
    Location
    UK - South Wales
    Posts
    1,762
    Thanks
    34
    Thanked
    17 times in 15 posts
    • Dorza's system
      • Motherboard:
      • Asus P5B Deluxe - WiFi
      • CPU:
      • Q6600 @ 3.06Ghz
      • Memory:
      • 2GB Crucial
      • Storage:
      • 500GB Samsung SpinPoint
      • Graphics card(s):
      • Geforce 9600GT
      • PSU:
      • Cosair HX520W
      • Case:
      • LianLi something something or other
      • Monitor(s):
      • Eizo FlexScan S1910 (1280*1024)
      • Internet:
      • 2mb Virgin (when they want to give me that: else 1mb)
    Works fine for me though, $Acme Cars needs to be $AcmeCars on the last print line.

  5. #5
    Senior Member ajbrun's Avatar
    Join Date
    Apr 2004
    Location
    York, England
    Posts
    4,840
    Thanks
    4
    Thanked
    25 times in 13 posts
    Doesn't 'count' need to be changed to '$count', then initialised?

    As far as I can tell, you're saying "keep looping round this code until $X is not less than count". Assuming I've understood it correctly, count must be a number. Therefore, above the loops, put:

    $count = 5;

    then in the loop, change 'count' to '$count'.

    That should then go through the loop 5 times.

    What error is PHP throwing at you anyway?

  6. #6
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS
    Quote Originally Posted by ajbrun
    Doesn't 'count' need to be changed to '$count', then initialised?

    As far as I can tell, you're saying "keep looping round this code until $X is not less than count". Assuming I've understood it correctly, count must be a number. Therefore, above the loops, put:

    $count = 5;

    then in the loop, change 'count' to '$count'.

    That should then go through the loop 5 times.

    What error is PHP throwing at you anyway?
    um... no, count is a php method to count the number of elemts in an array. see http://uk2.php.net/count

  7. #7
    Senior Member ajbrun's Avatar
    Join Date
    Apr 2004
    Location
    York, England
    Posts
    4,840
    Thanks
    4
    Thanked
    25 times in 13 posts
    Oh right - I didn't know that. Thanks .

  8. #8
    lazy student nvening's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    4,656
    Thanks
    196
    Thanked
    31 times in 30 posts
    Ah, what i was doing was opening it through my ftp program which was not opening it through the server - which i didnt realise!! Its working now thanks.
    (\__/)
    (='.'=)
    (")_(")

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Making PHP and MySQL Talk?
    By Dav0s in forum Software
    Replies: 4
    Last Post: 18-09-2005, 10:53 PM
  2. PHP 4.3 vs 5 (which one should I start learning?)
    By malfunction in forum Software
    Replies: 8
    Last Post: 08-02-2005, 03:28 PM
  3. PHP Questions and a book recommendation
    By Dorza in forum Software
    Replies: 2
    Last Post: 02-09-2004, 01:26 PM
  4. PHP web sites HELP
    By robbiehall in forum Software
    Replies: 12
    Last Post: 27-07-2004, 02:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •