473,396 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can't get_file_contents?

Ok, I am a newb to PHP, but I have a good backing in C++ and Java so I have been able to eek out what I need.

I was going though a 'mambo' conversion of a web plug in for Smart launch, a cafe' administration program.

Here is my code:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  $filename = 'data.dat';
  3.  $postvars = unserialize(file_get_contents($filename));
  4.  
  5.  $i = 0;
  6.  
  7.  for($i = 0; $i <= $postvars['ComputerCount']; $i++)
  8.  {
  9.   switch($postvars['Computer' . $i . '_State'])
  10.   {
  11.     case '0':
  12.      $statustext = "Unavailable / Off";
  13.      break;
  14.     case '1':
  15.      $statustext = "Available for use!";
  16.      break;
  17.     case '2':
  18.      $statustext = "Unavailable / In Use";
  19.      break; 
  20.   }
  21.  
  22.   switch($postvars['Computer' . $i . '_ConsoleType'])
  23.    {
  24.     case '0':
  25.  ?>
  26.      <div style="position:absolute;top:<? echo $postvars['Computer' . $i . '_X']; ?>px;left:<? echo  $postvars['Computer' . $i . '_Y']; ?>px;width:32px;height:32px;" onmouseover="return escape('<b>Computer #<? echo $i ?><br>Status:</b> <? echo $statustext ?>')">
  27.          <img src="images/pc_<? echo $postvars['Computer' . $i . '_State']; ?>.png" alt="Computer #<? echo $i ?>">
  28.      </div>
  29.  <?
  30.      break;
  31.     case '1':
  32.  ?>
  33.      <div style="position:absolute;top:<? echo $postvars['Computer' . $i . '_X']; ?>px;left:<? echo  $postvars['Computer' . $i . '_Y']; ?>px;width:32px;height:32px;" onmouseover="return escape('<b>XBOX<br>Status:</b> <? echo $statustext ?>')">
  34.          <img src="images/xbox_<? echo  $postvars['Computer' . $i . '_State']; ?>.png" alt="xbox"><br>
  35.      </div>
  36.  <?
  37.      break;
  38.     case '2':
  39.  ?>
  40.      <div style="position:absolute;top:<? echo $postvars['Computer' . $i . '_X']; ?>px;left:<? echo  $postvars['Computer' . $i . '_Y']; ?>px;width:32px;height:32px;" onmouseover="return escape('<b>PS2<br>Status:</b> <? echo $statustext ?>')">
  41.          <img src="images/ps2_<? echo  $postvars['Computer' . $i . '_State']; ?>.png" alt="ps2"><br>
  42.      </div>
  43.  <?
  44.      break;
  45.    }
  46.  }
  47.  
  48.  ?>
  49.  <script language="JavaScript" type="text/javascript" src="wz_tooltip.js"></script>
  50.  
  51.  

I keep getting an error though mambo of this "Warning: file_get_contents(data.dat): failed to open stream: No such file or directory in E:\inetpub\vhosts\pixelated.com\subdomains\XGN\htt pdocs\CMS\modules\mod_computerStatus.php on line 22 "

The file "data.dat" is in the correct directory, and my Smart Launch server has and does update to it correctly; but the code still can't see it. What am I doing wrong?
Feb 5 '07 #1
3 2939
check permissions
Feb 5 '07 #2
Motoma
3,237 Expert 2GB
Welcome to The Scripts.
Two things may be wrong: permissions, and working directory.
PHP scripts run from the permissions of the web-server. If this is a *nix machine, it is probably nobody, www, or apache. If this user does not have the permissions to access this file, then the call will fail.
Depending on the exact configuration of the web-server, not specifying a path could land you in any number of directories. If you are running in Windows you may even end up at C:\. Try specifying the entire path to see if it will work then.
Feb 5 '07 #3
steven
143 100+
Make sure data.dat is in the same directory as your PHP script, or change the $filename variable to indicate it's location.

Also confirm the webserver has read permissions on the file in question.
Feb 6 '07 #4

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

Similar topics

0
by: AK | last post by:
Hi all, I have a form which simulates a form collecting a person's info for a job. The form has the field's like fname, lname, address etc. The last field in the form is browse for resume and...
5
by: lawrence | last post by:
I've waited 6 weeks for an answer to my other question and still no luck, so let me rephrase the question. I know I can do this: <form method="post" action="$self"> <input type="text"...
1
by: farzad | last post by:
Hi I try to install php_ming.so in my php . I am using Redhat 8.0 php 4.2.2 apache 2.0.4. I am doing as the howto install file want me to do. as follow....
1
by: Randell D. | last post by:
Folks, I use Apache/PHP with Webazlier to view the log files. I get a number of user agents (web browsers?) that visit the website - For example: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT...
5
by: Scott D | last post by:
I am trying to check and see if a field is posted or not, if not posted then assign $location which is a session variable to $location_other. If it is posted then just assign it to...
1
by: lawrence | last post by:
What is the PHP equivalent of messaging, as in Java?
7
by: Adams-Blake Co. | last post by:
This may be OT a bit, so maybe someone can point me in the right direction. I want to test a script that sends out an e-mail. I want to test it locally on my Mandrake Linux 8.2 box. It runs OK...
2
by: Alex | last post by:
Is it more time-consuming to troubleshoot or just start from scratch. PHP used to work that's why I'm tempted to just re-install Linux.
11
by: 1965 | last post by:
Hi, All. I am new to PHP. Though I dug through this forum to try to find an answer to get_file_contents function, I failed. Please help with the below problem. I am testing building a page by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.