I'd like to make a simple form button which completely destroys the session when you click on it. I am just starting to use PHP for the first time, and do not see how I implement it into my HTML code.
What I'd like is simply a form button which will clear the session (and possibly an explanation as to how it works)
...
Lets say the url is http://example.com/product/3 and I only want to retrieve what is after http://example.com/product/. I found this, it echos the domain but how do I get the three. Its this method reliable? I'm using codeIgniter also.
<?php
function curPageURL() {
$pageURL = 'http';
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80...
Hi,
I need a PCRE expresssion (regex) to match and replace a certain attribute and value related to a markup element, something like this :
<div style="width:200px;"></div>
into
<div style="width:100px;"></div>
What I have now, parsed by simplehtmldom is the style content in plain text, like this :
width:200px;
How can I match ...
i have a class
like this
class im_a_class
{
static function not_empty() {...}
function render() { return array_filter($array,'self::not_empty') };
}
this code works in php 5.3.0 but doesn't work in version 5.2.8.
i had to put it out and use it like this
function not_empty() {...}
class im_a_class
{
function render() { return...
Right now I'm just using a simple
WHERE name LIKE '%$ser%'
But I'm running into an issue - say the search is Testing 123 and the "name" is Testing, it's not coming back with any results. Know any way to fix it? Am I doing something wrong?
...
Hello,
So i've been trying to write this little piece of code to read a file (status.txt), search it for 1 of 4 keywords and loop until either time runs out (5 minutes) or it finds one of the words. I've already written a few simple php scripts to write the words to a txt file, but I can't seem to get this part to work. It either does...
Here is how I read the data:
<?php
$id = $_GET["id"];
$number = mysql_real_escape_string($id);
$result = mysql_query('SELECT * FROM `mystory` where `id` = ' . "$number" . ' LIMIT 1');
$row = mysql_fetch_assoc($result);
echo $row['story'];
?>
The data is encoded as utf8_bin.
Insted of ı PHP outputs ?
Why is that? What I'm doing wrong...
I'm beginning to learn some Hadoop/MapReduce, coming mostly from a PHP background, with a little bit of Java and Python.
But, it seems like most implementations of MapReduce out there are in Java, Ruby, C++ or Python.
I've looked, and it looks like there are some Hadoop/MapReduce in PHP, but the overwhelming body of the literature se...
What would be a equivalent example in perl of the bellow code to create a Self-signed certificate ?
All i have available is Crypt::OpenSSL::RSA (if there is another module let me know so i can verify it is available or possible to install as i am not the admin/owner and cannot do it myself due to rights issue) which i havent found on th...
I've got a plugin that is declared and hooked following best practices described in this related question:
http://stackoverflow.com/questions/1615118/wordpress-accessing-a-plugins-function-from-a-theme
So it looks (platonically) like this:
if ( !class_exists( 'Foo' ) ) {
class Foo {
...
public function do_stuff() {
//...
hi,
i have a php application driven by mysql data. ie. when a user rates on a product .it gets stored in DB and the page gets refreshed. then also his ratings donot get showed up until cache is cleared. i have put the cache control code also .
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 J...
I can't believe anyone would normally object to documentation and comments, but whats the best practice (and practical) for doing so in PHP?
In JavaScript, you can document your code and then run a minimizer to produce a production version of your code for use. What about in PHP, does the extra lines of text affect performance? Should y...
I need a way to do this, If a mysql query dosn't retrieve any data, something happens. Here's an example.
$color="red";
$query = mysql_query("SELECT * FROM people WHERE shirt='$color'");
if($query = null){
echo 'No people wearing '.$color' shirts available.';
}
...
private static readonly byte[] IV = new byte[8] { 240, 3, 45, 29, 0, 76, 173, 59 };
public string Decrypt(string encryptedData,string key)
{
encryptedData = HttpUtility.UrlDecode(encryptedData);
byte[] buf = Convert.FromBase64String(encryptedData);
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
...
I am using PHP to match the following data type :
[["1200","135"],["127","13"]]
I want to extract all the numbers into a seperate array of arrays like this :
array(array(1200,135),array(127,13));
I am using preg_match to capture the elements but so far i am not even able to match them against a rule.
I will gladly appreciate if som...
I've been toying with the JanRain OpenID PHP Library, mostly following along with a tutorial I found on ZendZone.
How does one distinguish between users - especially Google users, who all end up using the same OpenID URL, https://www.google.com/accounts/o8/id ?
Basically, I'm at the point where I can detect that they have an OpenID acc...
Question is simple. How can I make 100% safe photo upload script with php? Is there any tutorials which shows all possible safeness's gaps? Do not offer me to look this question http://stackoverflow.com/questions/786507/uploading-photos-how-can-i-keep-our-website-safe-stable, because there they talk only about size. But I want to be sur...
PROBLEM
I have a nested PHP array that I need to populate from flat scalar
values. The problem is I cannot know ahead of time what the structure
of the nested PHP array will be until I get the request to fill in
the flat scalar values.
EXAMPLE
// example where we populate the array using standard PHP
$person['contact_info']['fname']...
I ran into a little problem today when I was creating a really quick script to scan lines files in a user specified directory for //todo:...
So I had a line like this:
if (stripos($data, '//todo:')) { //case-insensitive search ^^
//deal with the data appropriately
}
This did not find //todo: anywhere in any of the files! This was ...
I have a job board where a user submits his location, via Google-Maps API, which plots the job on a map.
The problem is, because it is a location based job board, I want to make the most broad input allowable a ZIP code (so users can either enter a ZIP code or address). Is there anyway to either parse the input to determine whether it'...