Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page blanks after simple elseif 1

Status
Not open for further replies.

LWolf

Programmer
Feb 3, 2008
77
US
My page is doing both view/edit with record maintenance at the top. Everything was fine until I started the edit section. I have basic code to set select boxes but that was it. I put in the main code and the screen goes blank. So I stripped it down to a basic elseif statement. The page works fine until this goes in.

Code:
<?php
elseif ($_GET['rec'] == 'edit'){
    echo "Hello";
}
?>

I know its not the php tags, and I have tested with a basic if statement that works...
Code:
if (4<5) {echo "Hello";}

As soon as I make it...
Code:
elseif (4<5) {echo "Hello";}[s][/s]
What the heck? Any insight would be great. I need to get past this.

Thanks,

K
 
elseif has to follow an if

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
It does.
Code:
if () {
    do things...
}

elseif () {
    screen goes blank
}
 
Hi

LWolf said:
It does not in your original code.

Code:
[teal]<?php[/teal]
[b]if[/b] [teal]([/teal][b]true[/b][teal]) {[/teal]
    [b]echo[/b] [i][green]'do things...'[/green][/i][teal];[/teal]
[teal]}[/teal]

[b]elseif[/b] [teal]([/teal][b]true[/b][teal]) {[/teal]
    [b]echo[/b] [i][green]'screen goes blank'[/green][/i][teal];[/teal]
[teal]}[/teal]
Code:
[teal]<?php[/teal]
[b]if[/b] [teal]([/teal][b]true[/b][teal]) {[/teal]
    [b]echo[/b] [i][green]'do things...'[/green][/i][teal];[/teal]
[teal]}[/teal]
[teal]?><?php[/teal]
[b]elseif[/b] [teal]([/teal][b]true[/b][teal]) {[/teal]
    [b]echo[/b] [i][green]'screen goes blank'[/green][/i][teal];[/teal]
[teal]}[/teal]

Please provide more context from the actual problematic code.

Feherke.
feherke.ga
 
Okay, so when you say,

"As soon as I make it..."


You don't actually mean that's what you do. ie. change the if .... into else if ...

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
An elseif statement must come after an If, but before an else if there is one. Where in the context of that structure is your elseif.

The blank Page suggests you are getting an error, but do not have errors set to be displayed. When developing its essential to have display_errors set to on, and ERROR_REPORTING set to E_ALL so you get everything, and are able to correct them as you go.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
It turns out that copy and paste is not all that it is cracked up to be! I had a space between my ? and the > tags. I rebuilt the section and found it.

I do have a new problem...the page works locally but when I upload it to the host I get this error when running it from the host...

"Fatal error: Call to a member function prepare() on a non-object in..."

The code line that it is referencing is...
Code:
$rows= $pdo->query("Select * From Employees");

Is there a setting on the host or does this line act differently when not run locally?
 
It means your $pdo variable is not an actual PDO object, and as such you cannot call a function from it. Check your PDO instance prior to making the query call.

How are you setting your $pdo variable?

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Yep...I gotta stop programming late at night! My last post I discovered that the problem was in my db_include_local.php file. I forgot to remove the "_local". Thanks for the post, it reminded me of this!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top