I'm writing some code and I need to write a number to a specific line. Here's what I have so far:
<?php
$statsloc = getcwd() . "/stats/stats.txt";
$handle = fopen($statsloc, 'r+');
for($linei = 0; $linei < $zone; $linei++) $line = fgets($handle);
$line = trim($line);
echo $line;
$line++;
echo $line;
I don't know where to continue a...
i need to get filename from file path string. For example, from this string \abc\def\filename.txt i need to get filename.txt
trying to do this with regexp:
$filepath="abc\filename.txt";
$filename = preg_replace("/.+\\/","",$filepath);
but it gives me an error. What regex i should use to solve this?
...
hello
i want to build a project using codeigniter, the project conisist of 2 levels, USER level and ADMIN level
i'm now building the ADMIN level, is it the best practice to make all my admin functions in 1 controller ? like add/modify/delete users and add/modify/delete admins etc....
or make many controllers everyone has it's job li...
In my .htaccess on my 127.0.0.1 running Apache on Linux:
# prepend and append files
php_value auto_prepend_file /var/www/..../prepend.php
php_value auto_append_file /var/www/..../append.php
So the prepend file is working fine, but the append file is not. I try to do it do unlink() operations on a www-data owned file and nothing. I'd l...
Hi guyz,
I need to get all contents of div class = "parent" using preg_match,
<div class = "parent">
<div id = "child1">
</div>
<div id = "child2">
</div>
</div>
Anyone?
...
I have this code:
$db->get()->query()
Now i want the get method's return to depend on:
$db->get()
return $db->query var;
but
$db->get()->query()
the get() method will return $this
...
Let's say that I want some generic error handling, which can be called from all over...
Ideally, I would like to just readirect to an error page using header('Location:... but, of course I can't do that it if any output has been written, so ...
1) how can I detect if any output has been written?
2) how can I load a new page if it has?
...
Hello, I have a multidimensional array object, and in a loop I would like to append an iterator to the key and obtain the value. Sample code for demonstration:
$array_object->example1 = 1;
$array_object->example2 = 2;
$i = 1;
while ($i <= 2) {
echo ($array_object->example . $i); //this does not work
//how to a...
I am using htmlpurifier library for sanitizing my incoming parameters. But it is not filtering null bytes (for e.g. %00). Am I missing something or the library does not support it? Will I be required to use a reg-ex? Thanks for any answers.
Edit:
I am using htmlpurifier with config options
$config = HTMLPurifier_Config::createDefault...
I'm attempting to parse a set of CSV data using PHP, but having a major issue. One of the fields is a long description field, which itself contains linebreaks within the enclosures.
My primary issue is writing a piece of code that can split the data line by line, but also recognize when linebreaks within the data should not be used. Th...
I have this form:
<form action="after.php" method="post" id="divulgacao">
<div style="float: left;width: 195px; margin-right: 10px;">
<p class="pdados">Your name</p>
<input class="campodivulgue" name="titulo" type="text" />
</div>
<div style="float: left;width: 195px; margin-right: 10px;">
<p class="p...
How do you avoid abusers for account systems requiring email activation? Abusers can basically hijack your account activation system to spam someone's (or multiple someone's) email's.
The most obvious solution is probably to set a limit of X reminders max per hour or per day. But: This doesn't give the non-abusing user the benefit of th...
I dropped all tables from a database then restore(import) a backup. and getting this error.
Should i repeat the process. or something else? Why this error is coming?
...
hey guys,
i really really need your help. I'm successfully setting up a connection to my ftp server. However I can't figure out how I can download a dynamic file from my server. I guess this would help a lot of other people as well cause i couldn't find a tutorial or explanation anywhere on the web.
I'm simply listing all of my files on...
I have a simple form.
Input fields, checkboxes, radio buttons and finally SUBMIT button.
I use jQuery to perform AJAX validation, however when a user presses ENTER inside the input field it submits the form!
How do I stop this from happening on this form (not all input fields)?
...
Hi guys,
$url = $_GET['url'];
echo "$url";
and I request
/test.php?url=ok
gives me ok as output..
but I use a url
test.php?url=http://google.com
gives me 403- Forbidden error..
I donno why it's not working ..
Please help me..
...
I am using CakePHP to write a web app and one of the requirements is to send users' emails after registration.
I had to create an email account on our server and then send the emails using smtp authentication, otherwise, google and yahoo (at least) refused to read my emails.
Does this come with major trade offs? As in speed of the app or...
hi,
In my application I have created many graphs using php and dom and I have one print button associated with each graph,so on click of each print button i need to print associated graph.how to achieve it.any suggestion???
...
Hey all,
I'm building a color class and I'm looking to add operations more(color, percentage) & less(color, percentage). This requires being able to add and subtract colors and I'm having a hard time with the arithmetic. How do I use RGB or HSB(HSV) or HEX to do operations like:
Operation - echo color('blue')->more('yellow', 100%);
b...
How do you retrieve the name of the script that included or required it?
Example:
script login.php has a require_once('validate.php') ... validate.php is also called by a number of other scripts. Other than manually setting a flag, is there a way to have validate.php know which script is including/requiring it?
...