Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 12-29-2005, 05:30 PM If/else not working
lerch's Avatar
Novice Talker

Posts: 5
Trades: 0
Im working with flat files, so Im trying to code a message were if the text file isnt there, it says something like "No comments yet"...But I keep getting the error that there is no file. Here is the php code for this message:
PHP Code:
<?php
if ("2.txt") {
   include 
"2.txt";
} else {
   echo 
"There are no comments yet.";
}
?>
But no matter what, I get this message as if the script it always trying to find "2.txt".


Warning: main(2.txt): failed to open stream: No such file or directory in /home/lerchism/public_html/blog/if.php on line 3

Warning: main(2.txt): failed to open stream: No such file or directory in /home/lerchism/public_html/blog/if.php on line 3

Warning: main(): Failed opening '2.txt' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/lerchism/public_html/blog/if.php on line 3


thanks
lerch is offline
Reply With Quote
View Public Profile Visit lerch's homepage!
 
 
Register now for full access!
Old 12-29-2005, 05:37 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
if (file_exists("2.txt"))

if ("2.txt") will always be false because "2.txt" will never be true
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 12-29-2005, 06:14 PM
lerch's Avatar
Novice Talker

Posts: 5
Trades: 0
Ah, Thank you Everything works great now.
lerch is offline
Reply With Quote
View Public Profile Visit lerch's homepage!
 
Reply     « Reply to If/else not working
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.20160 seconds with 12 queries