TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 03-22-2011, 08:52 PM   #1 (permalink)
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
Old 03-23-2011, 03:30 PM   #2 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

put this line $stringrandom = ""; inside the function definition. instead of out where the function can't see it.
tony is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Handling errors Sirupsen General 0 09-16-2009 07:30 PM
How do you handle your (custom) errors? Runar General 1 06-27-2009 08:17 PM
modifying PHP.ini allworknoplay General 3 04-27-2009 02:50 PM
Coding errors KingOfTheSouth The Lounge 7 03-11-2009 02:02 AM
Muting errors in PHP5 Ross General 4 06-30-2008 03:13 PM


All times are GMT. The time now is 10:44 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design