The code below doesn't seem to work or find anything on an array. I'm using "in_array" to search for the needle in the stack. I also tried exploding the contents with comma separated and won't work. Any suggestions? Also I tried "array_search".
$q4 = "SELECT domain_name,slots_config.bid FROM slots_pid,slots_config,slots_sites
WHERE slo...
Today at work someone tried to convince me that:
{$obj->getTableInfo()}
is fine for smarty/mvc/templating because it is using an objects method. I argued that because it makes a call to the database it has no place being there and it should be in the controller (we don't actually use MVC). Am I right in my understanding of the logical...
I'm having a problem uploading files in PHP. When I submit, $_FILES[] is empty. I feel like this is such a n00b question :/
My form:
<form method="post" action="uploadfile.php">
<input type="hidden" name="MAX_FILE_SIZE" value="300000" />
Image: <input name="ImageFile" type="file" /><br />
<input type="submit" value="Add Image" /><b...
I'm looking to include other folders in my include path for PHP. I've seen this question:
http://stackoverflow.com/questions/24622/setting-php-include-path-on-a-per-site-basis
BUT I don't want to replicate the system path (I suppose I could but then it won't update if the system path is updated). What I would rather is to simply have a...
I have a simple mysql DB and use this PHP code to update it.
mysql_query("REPLACE INTO `$db_table` (username, live, datetime, ip)
VALUES ('$username', '1', '$timeofentry', '$ip')");
I use REPLACE INTO along with a primary key on "username" to let users bump themselves to the top of the most recent list...
I would like to add a bump ...
At work we use a .ini file to set variables prior to calling the rest of the framework (I think it goes
function getConfigVars(){
//read my_config.ini file
....
//call framework
}
and I have always wondered if there was a benefit to doing it that way.
It seems to me that you then have to write access rules to stop people ...
I have records in my database that are searched with user input, and initially, this was sufficient for finding the correct records.
"SELECT id FROM plants WHERE Flower LIKE '%" . $sanitizedUserInput . "%'"
This was working all well and good, but then things started to happen like, searching 'red' was getting plants with the character...
how can I read the contents of stdin (up until EOF) into a string in PHP?
...
Hi
I have the following .ini configuration working fine for positive integers, but not negative integers.
routes.nd.type = "Zend_Controller_Router_Route_Regex"
routes.nd.route = "news/(\d+)/d"
routes.nd.defaults.controller = "news"
routes.nd.defaults.action = "display"
routes.nd.map.id = 1
How to make it detect negative integers? App...
What's considered the best practice these days for sanitizing data from a PHP email form?
I'm currently using something like this...
$msg = $_POST['msg'];
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
$name = $_POST['name'];
$subject = "Message from the MY_WEBSITE website e-mail system";
$message = "From: " . $name . "\...
I install PHP using the PHP installer. And so, the PEAR package is not included. The question now is I need PEAR for Symfony upgrade purpose, but the resources I found on the internet seem to cater for the case where PEAR package is already included in PHP package.
What is the best way to install PEAR extension, given that I use PHP ins...
Hi,
i am currently working on a class that generates diagramm's as pictures with php. I want to load these pictures dynamically with jquery. How can i do that?? I wont have a real picture file, just the content of the file when i call it with ajax... And i cant simply define the phpscript as the src because i need to pass Post Parameter...
I am trying to trieve a list of files where a field ARTICLE_NO is a certain number. At the moment, I have a files table, with columns ARTICLE_NO, FILENAME and USERNAME. There is one record, with values 1, x.txt and user respectively. $pk is assigned to 1 in my php code. However, the following code only produces NULL, and I am unsure why....
I have the following code, which will retrieve a filename from a table and make a link to it. What I want to do, is have it so I can refer to $filesList later on, and it will contain a single block of html code with links to as many files as there are files.
I thought adding to the previous variable would be the easiest way to do this, ...
I have a html form for uploading a file, which is as follows:
$uploadhtml = htmlspecialchars(json_encode("<form action='up.php' method='post'
enctype='multipart/form-data'>
<label for='file'>Filename:</label>
<input type='file' name='file' id='file'/>
<br />
<input type='hidden' name='pk' value='".$pk."'>
<input type='hidden' name='use...
How to implement NGramTokenizer in zend lucene? is it allready implemented somewhere?
...
I am generating links from the following php code. The links appear in the browser, and the generated html code seems fine, however the links are not click-able. I have tested this in IE and FF, and tried to see with FireBug to no avail.
The code to generate my form
$uploadhtml = htmlspecialchars(json_encode("<form action='up.php' meth...
For hobby purposes, I have a shared space on a hosting server that is providing, as many of them are, both PHP and Perl CGI. I have read on several places that CGI scripts are obsolete now, I think mainly for performance issues (like http://stackoverflow.com/questions/313083/is-php-or-vanilla-perl-cgi-faster).
But since I just started ...
I need to filter the unreliable $_SERVER['PHP_SELF'] varialbe. Is this a good approach:
function filterPhpSelf($str)
{
$phpself = basename(__FILE__);
$str = substr($str, 0, strpos($str,$phpself)) . $phpself;
return $unsafeStr;
}
where $str is $_SERVER['PHP_SELF']?
...
PHP functions such as 'array_map' take a callback, which can be a simple function or a class or object method:
$array2 = array_map('myFunc', $array);
or
$array2 = array_map(array($object, 'myMethod'), $array);
But is there a syntax to pass a method which is bound within the iteration to the current object (like 'invoke' in Prototype.j...