473,507 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use if statement (it is false in all time)?

24 New Member
Hello everyone,

I am trying to read text file to get my data from it, but unfortunatly, there is something wrong, and i am unable to find it, so would you please help me in that?

The php code is:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $DataFile = "myfile.php";
  3. $FileStream = fopen($DataFile, 'r');
  4. $Line = fgets($FileStream);
  5. if($Line == "This is the first line")
  6. {
  7.     $Line = fgets($FileStream);
  8.     echo $Line;
  9. }
  10. else
  11. {
  12.     echo "Wrong file";
  13. }
  14. fclose($FileStream);
  15. ?>
  16.  
And myfile.php contain:
Expand|Select|Wrap|Line Numbers
  1. This is the first line
  2. This is the second line
  3.  
Finally, the result is:
Expand|Select|Wrap|Line Numbers
  1. Wrong file
  2.  
Nov 28 '10 #1
2 1161
johny10151981
1,059 Top Contributor
This type of issue always confused me. But The thing is when you are reading first line you are not getting
"This is the first line"
You are getting two possible value depending your Editor
1."This is the first line\r"
2."This is the first line\r\n"

Make your judgement
Nov 29 '10 #2
hdbbdh
24 New Member
Thank you very very very much Johny.
Nov 29 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6378
by: FuRiOuS1 | last post by:
Hi, i need some help with a select statement, i tried many different MySQL fucntions and looked through the MySQL manual, and it didnt help me any. What i want to do is select all rows from a table...
5
2236
by: Hatul Shilgy | last post by:
Hi I'm facing a very strange problem here. My code looks like this if(A == null return doSomethingWith(A.b) When I run my code (in debug mode), I get a NullReferenceException -- and on...
1
946
by: monitor-radiation | last post by:
I'm trying to get my program to write a blank line if the array segment starts with a 0 or a 1. I have the if statment written down fine (i believe), however the program skips the whole statement...
20
3893
by: John Salerno | last post by:
I'm starting out with this: try: if int(text) 0: return True else: self.error_message() return False except ValueError: self.error_message()
22
5399
by: pbd22 | last post by:
hi. I am having probelms with an update statement. every time i run it, "every" row updates, not just the one(s) intended. so, here is what i have. i have tried this with both AND and OR and...
0
1107
by: hastha23 | last post by:
Dear Friends, My oracle Version is 10g. I calling a function from sql select same time function body contain DML statement,that time is possible call function from sql? and again one, ...
1
2354
DTV12345
by: DTV12345 | last post by:
Hello! I am attempting to create a query that calculates a time value from GMT to Pacific time. It is, of course, based on the calendar date that I will have to figure out whether or not...
4
1811
by: ailinseng | last post by:
Hi, I faced some difficulty for select statement in a view? My problem is when I query this view, it consumes more than 4 mins in order to come out the data. My question is how to optima this...
2
1220
by: MBeckford05 | last post by:
Hi Everyone, I have written the code which gives the system time in a window. But I need also to have the Internet address and the port number of the client in the window. the TimeserverRF...
3
1467
by: merrygreat | last post by:
When I was running the above program it gave the result of "if" statement every time. It didn't matter if the "if Statement" was true or false. #!/usr/bin/perl-w use Tk; $mw= MainWindow->new;...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5041
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.