php

How can I make a php script add a tab to every line of an include file?

Within my HTML, I have a php script that includes a file. At that point, the code is indented 2 tabs. What I would like to do is make the php script add two tabs to each line. Here's an example: Main page: <body> <div> <?php include("test.inc"); ?> </div> </body> And "test.inc": <p>This is a test</p> <div> <p>This i...

$getJSON not being recognized as an array

Hello, I'm trying to use jQuery's $getJSON to send an array of 'ids'. Here's what my jQuery looks like: var calendarIds = []; $("#jammer :selected").each(function(i, selected){ calendarIds[i] = $(selected).val(); }); $.getJSON("test.php", { start: start.getTime() / 1000, end: end.getTime() / 1000, calendarid:...

Problem getting image to save.

I am creating an image dynamically using php. The image is being created if I go in and make the file first. However, if I don't create the file manually then I get the following error. Warning: imagegif() [function.imagegif]: Unable to open 'filename2.png' for writing in /www/vhosts/yourraceresults.com/htdocs/trial/TextToImage.inc.ph...

How to get file name from full path with PHP?

For example,how to get Output.map from F:\Program Files\SSH Communications Security\SSH Secure Shell\Output.map with PHP? ...

Question about preg_replace in PHP

In PHP what is the difference between using \1 or $1 as $replacement in preg_replace()? They both work and seem to do the exact same thing, but I think I'm missing something here. ...

Limit download count with text file in PHP

if ($_SERVER['REQUEST_METHOD']=='GET' && $_GET['download']==='1') { $handle = fopen('lastdownload.txt','rw'); $date = @fread($handle,filesize('lastdownload.txt')); if (time() - 30 * 60 > $date) { fwrite($handle,time()); header('Content-type: application/zip'); header('Content-Disposition: attachment; filename="dwnld_'.date('d_m_Y...

Stop resubmitting a page after a post with F5

After submitting a form with post method f5 will resubmit that. What's the best to avoid this without redirecting a page. Idon't like to disturb the user like this. Stackoverflow are immune to f5 but i don't see any redirection after asking a question. ...

MySQL Database has non escaped single quotes in entires ... How to show them?

Hello, The database has a ton of entries that were not escaped because they were inputted manually when they were inserted so they look like: Don't inside of the entry, but when I try to display them they have a weird characters when I output in PHP. Before I would put anything into the database I would usually use mysqli_real_escape_s...

PHP mail isn't sending - headers set incorrectly?

I have successfully sent mail using PHP's mail() function before, and for my password reset notification e-mail, I copied the syntax I was using elsewhere, but I guess I messed it up, as it's not arriving at its destination. Here is the code I'm using: $headers = 'To:'.$email."\r\n"; $headers .= 'From: [email protected]'."\r\n...

Dependency Injection in PHP

I have been looking into Dependency Injection. Am I on to something or is it completely off? Is the code good or bad - Dependency Injection or not? The below code is the foundation for a CMS system Right now there is a table called "page_details" with all the web pages stored in it. Directory/file structure .htaccess index.php cla...

PHP Force download return corrupted file!

Hi I'm currently working on some php - zend framework project on my osx - apache. The problem is when ever I want to force the download of some files using my php application the downloaded files is corrupted and the size of the file is 5.4 kb! I've tried so many changes in my code and even used some classes to force the download but sti...

Dynamic CSS and Javascript

How does one create Dynamic CSS and JavaScript On-The-Fly (using PHP). This needs to be done as different pages have different set of elements sometimes, so wrapping and sending a large CSS/JS everytime would be overkill. And why do many sites have link tags like this: <link rel='stylesheet' type='text/css' href='css/style.css?pg_id=43&...

kohana quotes in query.

hey, i want to format a date in mysql using DATE_FORMAT(tblnews.datead, '%M %e, %Y, %l:%i%p') i cant seem to get the quotes right , so i keep getting errors. how would you put this in a query? ...

removing new lines except in <pre>

I want to remove new lines from some html (with php) except in <pre> tags where whitespace is obviously important. ...

tcpdf - start with existing PDF document

I have several PDF templates that I would like to load and modify and output using tcpdf. Is it possible to load an existing PDF and use it as a starting point in tcpdf? ...

Simple Php Echo

I am just starting to learn php, how would I initiate a echo statement after a submit button is pushed, or even a anchor tag. Here is my code so far form name="myform" method="get" actions="madlib01.php" Name: <input type="text" name="name" /> <br /> <input type="submit" name="submit" /> form <?php $Name = $_GET['name']; ...

Generating Luhn Checksums

There are lots of implementations for validating Luhn checksums but very few for generating them. I've come across this one however in my tests it has revealed to be buggy and I don't understand the logic behind the delta variable. I've made this function that supposedly should generated Luhn checksums but for some reason that I haven't...

In RegEx, how do you find a line that contains no more than 3 unique characters?

Hey guys, I am looping through a large text file and im looking for lines that contain no more than 3 different characters (those characters, however, can be repeated indefinitely). I am assuming the best way to do this would be some sort of regular expression. All help is appreciated. (I am writing the script in PHP, if that helps) ...

Translating php app with gettext

From my previous questions about gettext, one of the biggest benefits of using PHP's gettext extension instead of other methods of language translation was that it is super easy to have other people make translation files with a program called Poedit. Now I have gettext working in my app but I have not made any translation files yet, ...

Localize current time in PHP

Trying to display current time with PHP (using this): $date = date('m/d/Y h:i:s a', time()); echo $date; As simple as it gets. How do I localize it? I want to translate the months and days to Hebrew. Thanks. ...