#39437 [Opn->Bgs]: Im trying to use a function to write to a table but it won't work
| From: | mj@php.net | Date: | Sat, 11 Nov 2006 14:18:17 +0000 |
| Subject: | #39437 [Opn->Bgs]: Im trying to use a function to write to a table but it won't work | ||
| References: | 1 | Groups: | php.mirrors |
| Request: | Send a blank email to php-mirrors+get-33265@lists.php.net to get a copy of this message | ||
ID: 39437
Updated by: mj@php.net
Reported By: craig at 321movers dot com
-Status: Open
+Status: Bogus
Bug Type: Website problem
Operating System: linix
PHP Version: Irrelevant
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2006-11-08 19:41:19] 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.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39437&edit=1