Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,218 members, 7,807,745 topics. Date: Wednesday, 24 April 2024 at 06:19 PM

A PHP Programming Problem...im Stuck - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / A PHP Programming Problem...im Stuck (1823 Views)

Everyday PHP Programming Challenge (solved) / I Need Advanced PHP Programming,ajax And JS Ebooks, Pls!!! / Basics Of PHP Programming? (2) (3) (4)

(1) (Reply) (Go Down)

A PHP Programming Problem...im Stuck by freshp(m): 8:23am On Nov 05, 2014
I kindly need help in detecting the error in this code...it is from a video tutorial[Lynda.com - PHP with MySQL Essential Training] i am following to learn php. According to his instructions which i followed to the letter things should work(and it did on the video) but when i tried it on my system i kept getting the errors as shown below..

what i'm i doing wrong and how do i go about correcting it...

Here is the raw code itself

<?php
// This is how you redirect to a new page
function redirect_to($new_location)
{
header("Location: " . $new_location);
exit;
}

$logged_in = $_GET['logged_in'];
if ($logged_in == "1"wink {
redirect_to("basic.html"wink;

} else{
redirect_to("http://www.lynda.com");
}

?>

the images below show both the error and a capture of the code from notepad++ for accurate analysis.
Please i need someone to kindly tell me step by step what do to move forward
thanks

Re: A PHP Programming Problem...im Stuck by jacob05(m): 8:32am On Nov 05, 2014
Hmmm. Try removing extra spaces and newline... The error occurred because something is already sent to the browser with processing the page..
Re: A PHP Programming Problem...im Stuck by freshp(m): 9:03am On Nov 05, 2014
jacob05:
Hmmm. Try removing extra spaces and newline... The error occurred because something is already sent to the browser with processing the page..
thanks for the prompt response..i have tried it and even checked and rechecked..the thing is i am a newbie and still learning so all the line where the errors occurred i have checked.
this is a direct capture from the video itself...just take a look and you will see that it is exactly(i think so) as my own above.
thanks once again.

Re: A PHP Programming Problem...im Stuck by codemarshal08(m): 9:09am On Nov 05, 2014
place Ob_start(); on the top of Your Page.
For More Info on header Errors :
http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php

1 Like

Re: A PHP Programming Problem...im Stuck by jacob05(m): 9:13am On Nov 05, 2014
Try Removing newline on line 12 and 16 in your code
Re: A PHP Programming Problem...im Stuck by jacob05(m): 9:14am On Nov 05, 2014
codemarshal08:
place Ob_start(); on the top of Your Page.
For More Info on header Errors :
http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php

Or try ob_start as suggested

1 Like

Re: A PHP Programming Problem...im Stuck by freshp(m): 10:22am On Nov 05, 2014
thanks i will try it ..thanks once again.
Re: A PHP Programming Problem...im Stuck by freshp(m): 3:47pm On Nov 06, 2014
thanks for all the support
jacob05:

Or try ob_start as suggested
codemarshal08:
place Ob_start(); on the top of Your Page.
For More Info on header Errors :
http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php
jacob05:
Try Removing newline on line 12 and 16 in your code

the problem was actually from me..there was nothing wrong with the code..it was in the typing of the address on the browser that i had the problem

i should have typed
http://localhost/php/sandbox/redirect.php?logged_in%20=0

but i was typing
http://localhost/php/sandbox/redirect.php?logged_in%20 =0

Notice the space before the equal to sign....there shouldn't have been any space there...

chaii i had 3 whole sleepless nights with this tiny issue..i doff my hat to you guys ahead..it wasn't an easy road.. wink wink
thanks once again. i hope you will all be there for me as i climb on.. cheesy cheesy
Re: A PHP Programming Problem...im Stuck by jacob05(m): 3:56pm On Nov 06, 2014
freshp:
thanks for all the support

the problem was actually from me..there was nothing wrong with the code..it was in the typing of the address on the browser that i had the problem

i should have typed


but i was typing
http://localhost/php/sandbox/redirect.php?logged_in%20 =0

Notice the space before the equal to sign....there shouldn't have been any space there...

chaii i had 3 whole sleepless nights with this tiny issue..i doff my hat to you guys ahead..it wasn't an easy road.. wink wink
thanks once again. i hope you will all be there for me as i climb on.. cheesy cheesy


You're welcome bro
Re: A PHP Programming Problem...im Stuck by freshp(m): 4:47pm On Nov 06, 2014
grin grin grin
Re: A PHP Programming Problem...im Stuck by codemarshal08(m): 4:51pm On Nov 06, 2014
Hihi, it's nice you figured it out....Welcome to Programming World !
Re: A PHP Programming Problem...im Stuck by dsypha(m): 5:37pm On Nov 06, 2014
Please wat text editor is this? Its sleek. I love it
Re: A PHP Programming Problem...im Stuck by codemarshal08(m): 5:48pm On Nov 06, 2014
dsypha:
Please wat text editor is this? Its sleek. I love it
Dat Looks like SublimeText.
http://www.sublimetext.com
Re: A PHP Programming Problem...im Stuck by 1jimax: 1:11pm On Nov 07, 2014
Nah dats NOtepad ++ hw can u call dat editor sublime na wa for u ooooooo
Re: A PHP Programming Problem...im Stuck by codemarshal08(m): 1:23pm On Nov 07, 2014
1jimax:
Nah dats NOtepad ++ hw can u call dat editor sublime na wa for u ooooooo
u are very funny ! Read My Post Well...... "Dat looks like"..... Which means, i was not Certain about it.
Re: A PHP Programming Problem...im Stuck by dsypha(m): 7:51am On Nov 08, 2014
1jimax:
Nah dats NOtepad ++ hw can u call dat editor sublime na wa for u ooooooo
Its not notepad++. Looks more like sublime, just thrilled hw he could customize it this much.
Re: A PHP Programming Problem...im Stuck by Djtm(m): 1:36pm On Nov 08, 2014
dsypha:

Its not notepad++. Looks more like sublime, just thrilled hw he could .customize it this much.
Thats notepad++mehn!!!! I use the same theme.
I've edited the theme tho (fonts and stuffs).

Re: A PHP Programming Problem...im Stuck by 1jimax: 10:56pm On Feb 20, 2015
i jst wonder hw he did not see the notepad++ logo at the top

(1) (Reply)

A Question For Yii2 Users / Why I Think Animation Is A Better Career Path Compared To Software Development / I Need To Learn Programming Seriously

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 21
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.