Jump to content

file and echo help


adamriley

Recommended Posts

taken.php

<?php
session_start();
$adam = $_SESSION['dir'];
$pfile = fopen("Places/$adam.txt","r");
    rewind($pfile);
        
        while (feof($pfile)) {
        $line = fgets($pfile);
        $tmp = explode(':', $line);
        $name = $tmp[0];
        fclose($pfile);
}
?>

 

$_SESSION['dir'] = England

 

England.txt

 

Adam Riley:adam162@******.com:9846

 

I would hope that is echo's the "Adam Riley" bit of the file but it does not

 

 

Link to comment
Share on other sites

<?php
session_start();
$adam = $_SESSION['dir'];
$pfile = fopen("Places/$adam.txt","r");
    rewind($pfile);
        
        while (feof($pfile)) {
        $line = fgets($pfile);
        $tmp = explode(':', $line);
        $name = $tmp[0];
        fclose($pfile);
}
error_reporting(E_ALL);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Foot Ball game card || Place Taken</title>
</head>
<body bgcolor="#FF0000" text="#000000">
<div id="Text2" style="position:absolute;left:31px;top:158px;width:698px;height:64px;z-index:0;" align="left">
<font style="font-size:27px" color="#FFFF00" face="Arial">This slot has already been taken by </font><font style="font-size:27px" color="#0000FF" face="Arial"><?php echo $name ?></font></div>
<div id="Text1" style="position:absolute;left:34px;top:95px;width:660px;height:32px;z-index:1;" align="left">
<font style="font-size:27px" color="#FFFF00" face="Arial">You have selected </font><font style="font-size:27px" color="#0000FF" face="Arial"><?php echo $_SESSION['dir'] ?></font></div>
<div id="Text3" style="position:absolute;left:280px;top:17px;width:305px;height:36px;z-index:2;" align="left">
<font style="font-size:32px" color="#FFFF00" face="Arial"><u>Football Game Card</u></font></div>
<input type="submit" id="Button1" onclick="window.close();return false;" name="Button1" value="Close" style="position:absolute;left:211px;top:271px;width:339px;height:72px;font-family:Arial;font-size:19px;z-index:3">
</body>
</html>

 

Theres the full file

Link to comment
Share on other sites

Changed it and now i get

 

Notice: A session had already been started - ignoring session_start() in C:\xampp\htdocs\Game\Check\Taken.php on line 3

Warning: feof(): 7 is not a valid stream resource in C:\xampp\htdocs\Game\Check\Taken.php on line 8

Warning: fgets(): 7 is not a valid stream resource in C:\xampp\htdocs\Game\Check\Taken.php on line 9

Warning: fclose(): 7 is not a valid stream resource in C:\xampp\htdocs\Game\Check\Taken.php on line 12

 

 

Link to comment
Share on other sites

I took your code and simplified it by using the file function to read the file:

<?php
error_reporting(E_ALL);
session_start();
$adam = $_SESSION['dir'];
$tmp = file("Places/$adam.txt");
list($name) = explode(':',$tmp[0]);
?>

 

Ken

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.