php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39437 Im trying to use a function to write to a table but it won't work
Submitted: 2006-11-08 19:41 UTC Modified: 2006-11-11 14:18 UTC
From: craig at 321movers dot com Assigned:
Status: Not a bug Package: Website problem
PHP Version: Irrelevant OS: linix
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: craig at 321movers dot com
New email:
PHP Version: OS:

 

 [2006-11-08 19:41 UTC] craig at 321movers dot com
Description:
------------
This function will not write to the file.
It works find as regular code.
I also could not create a working function containing a few if statements.


Reproduce code:
---------------
function tablewrite(){
fwrite($fh, '<td><div align=center>');
$text = $leadnum2;
fwrite($fh, $text);
fwrite($fh, '</div></td>');
fwrite($fh, '<td><div align=center>');
$text = $date;
fwrite($fh, $text);
fwrite($fh, '</div></td>');
fwrite($fh, '<td><div align=center>');
$text = $visitorip;
fwrite($fh, $text);
fwrite($fh, '</div></td>');
fwrite($fh, '<td><div align=center>');
$text = $referer;
fwrite($fh, $text);
fwrite($fh, '</div></td>');
fwrite($fh, '<td><div align=center>');
$text = $_POST['Name'];
fwrite($fh, $text);
fwrite($fh, '</div></td>');
fwrite($fh, '<td><div align=center>');
$text = $_POST['Move_Date'];
fwrite($fh, $text);
fwrite($fh, '</div></td>');
fwrite($fh, '<td><div align=center>');
$text = $_POST['City_From'];
fwrite($fh, $text);
fwrite($fh, '</div></td>');
fwrite($fh, '<td><div align=center>');
$text = $_POST['State_From'];
fwrite($fh, $text);
fwrite($fh, '</div></td>');
fwrite($fh, '<td><div align=center>');
$text = $_POST['Zip_From'];
fwrite($fh, $text);
fwrite($fh, '</div></td>');
fwrite($fh, '<td><div align=center>');
$text = $_POST['City_To'];
fwrite($fh, $text);
fwrite($fh, '</div></td>');
fwrite($fh, '<td><div align=center>');
$text = $_POST['State_To'];
fwrite($fh, $text);
fwrite($fh, '</div></td>');
fwrite($fh, '<td><div align=center>');
$text = $_POST['Phone'];
fwrite($fh, $text);
fwrite($fh, '</div></td>');
fwrite($fh, '<td><div align=center>');
$text = $_POST['Email'];
fwrite($fh, $text);
fwrite($fh, '</div></td>');
fwrite($fh, '<td><div align=center>');
$text = $_POST['Move_Size'];
fwrite($fh, $text);
fwrite($fh, '</div></td>');
fwrite($fh, '<td><div align=center>');
$text = $_POST['Additional_Comments'];
fwrite($fh, $text);
fwrite($fh, '</div></td></tr>');
fwrite($fh, $newline);
fclose($fh);
}

Expected result:
----------------
write a new line to a table. Works fine as regular code.

Actual result:
--------------
does not write.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-11 14:18 UTC] mj@php.net
You are missing an

$fh = fopen(...);

And make sure that variables such as $leadnum2 are defined inside the scope of tablewrite().

See http://php.net/variables.scope for details.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Jun 17 00:00:02 2026 UTC