×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Page blanks after simple elseif

Page blanks after simple elseif

Page blanks after simple elseif

(OP)
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";} 
What the heck? Any insight would be great. I need to get past this.

Thanks,

K

RE: Page blanks after simple elseif

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

RE: Page blanks after simple elseif

(OP)
It does.

CODE

if () {
    do things...
}

elseif () {
    screen goes blank
} 

RE: Page blanks after simple elseif

Hi

Quote (LWolf)

It does.
It does not in your original code.

CODE --> PHP correct

<?php
if (true) {
    echo 'do things...';
}

elseif (true) {
    echo 'screen goes blank';
} 

CODE --> PHP Parse error: syntax error, unexpected 'elseif' (T_ELSEIF)

<?php
if (true) {
    echo 'do things...';
}
?><?php
elseif (true) {
    echo 'screen goes blank';
} 

Please provide more context from the actual problematic code.

Feherke.
feherke.ga

RE: Page blanks after simple elseif

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

RE: Page blanks after simple elseif

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

RE: Page blanks after simple elseif

(OP)
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?

RE: Page blanks after simple elseif

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

RE: Page blanks after simple elseif

(OP)
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!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close