Thread: errors help
View Single Post
Old 03-22-2011, 08:52 PM   #1 (permalink)
Tim Dobson
The Contributor
 
Tim Dobson's Avatar
 
Join Date: Feb 2010
Posts: 69
Thanks: 16
Tim Dobson is on a distinguished road
Arrow errors help

ok so i have been plodding a long with a big php file now and input some stuff...


PHP Code:
<?php
if(isset($_POST['setpaste']) && !empty($_POST['setpaste'])) {
$thehead $_REQUEST["addpastehead"];
$thebody $_REQUEST["addpaste"];
//replace blank lines for the break tag
$thebody preg_replace('/[\n\r]+/''<br />'$thebody);
$randnumb "";
$stringrandom "";
function 
genRandomString() {
    
$length 30;
$characters "0123456789abcdefghijklmnopqrstuvwxyz";
    for (
$p 0$p $length$p++) {
        
$stringrandom .= $characters[mt_rand(0strlen($characters))];
    }
    return 
$stringrandom;
}
$randnumb genRandomString();
$randnumb2 genRandomString();

$thefilename 'paste_boardnum1'$randnumb $thehead $randnumb2 '.php';
$checkfile 'pasteboard/' $thefilename;
if (
file_exists($checkfile)) {
    die (
'There was an error in the process... Please try again');
}
//write new note
$myFile "pasteboard/" $thefilename;
$fh fopen($myFile'w') or die("can't open file");
$stringData '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>' 
$thehead '</title>
</head>

<body>' 
$thebody '</body>
</html>'
;
fwrite($fhutf8_encode($stringData));
fclose($fh);
//header( 'refresh: 5; url=pasteboard/' . $thefilename );
echo '<a href="pasteboard/' $thefilename '">View file</a>';
}
?>

and great this worked!
kind of..

it puts the file alright infact it out puts everything alright from what i can see only when the data is submitted and this code is extracted it outputs these errors...


Notice: Undefined variable: stringrandom in E:\domains\s\sb0t.tentun.co.uk\user\htdocs\index.p hp on line 610

Notice: Uninitialized string offset: 36 in E:\domains\s\sb0t.tentun.co.uk\user\htdocs\index.p hp on line 610

Notice: Undefined variable: stringrandom in E:\domains\s\sb0t.tentun.co.uk\user\htdocs\index.p hp on line 610

Notice: Uninitialized string offset: 36 in E:\domains\s\sb0t.tentun.co.uk\user\htdocs\index.p hp on line 610

line 610 which would be the } after return $stringrandom;

Anyone got any idea what would be the fix to this to where i have gone wrong? much appreciated thanks
Tim Dobson is offline  
Reply With Quote