php

[PHP] md5(uniqid) makes sense for random unique tokens?

I want to create a token generator that generates tokens that cannot be guessed by the user and that are still unique (to be used for password resets and confirmation codes). I often see this code; does it make sense? md5(uniqid(rand(), true)); According to a comment uniqid($prefix, $moreEntopy = true) yields first 8 hex chars = ...

After compiling PHP from source are the devel libraries still needed?

After compiling PHP from source are the devel libraries still needed? For example, I am building a newer version of PHP from source than is on our dev servers. I installed alot of [extension i.e. mysql, postgresql, curl, etc]-devel packages in order for the configure from the dev server setup to work. Do i still need these after php has ...

Which location to save uploaded files

hello! I am using php and i have written codes to allow a user upload a file. For testing purposes, i have saved the file to D:/final/temp/test.xls. Then i generate another file and save it to the same location. This file can be downloaded by the user. But if an actual user would be using my application, where should the location point ...

sprintf and % signs in text

A problem I recently ran into was that when trying to update a field in my database using this code would not work. I traced it back to having a % sign in the text being updated ($note, then $note_escaped)... Inserting it with sprintf worked fine though. Should I not be using sprintf for updates, or should it be formed differently? I d...

PHP regex - find and replace

Hi, I am trying to do this regex match and replace but not able to do it. Example <SPAN class="one">first content here</SPAN> <SPAN class="two">second content here </SPAN> <SPAN class="three">one; two; three; and more.</span> <SPAN class="four">more content here.</span> I want to find each set of the span tags and replace with somet...

mysql error in php

i'm trying to run this php code which should display a quote from mysql, but can't figure out where is it going wrong. the result variable is null or empty. can someone help me out. thanks! <?php include 'config.php'; // 'text' is the name of your table that contains // the information you want to pull from $rowcount = mysql_query("sel...

PHP: how can a class reference its own name?

In PHP, how can a class reference its own name? For example, what would the method look like to do this? Dog::sayOwnClassName(); //echos "Dog"; Update I see that everyone is saying get_class($this). But that's not correct. That would work if I were creating an instance of Dog. I'm asking about calling a method of the Dog class itsel...

How to decode an array of json object

I have an array of json objects like so: [{"a":"b"},{"c":"d"},{"e":"f"}] What is the best way to turn this into a php array? json_decode will not handle the array part and returns NULL for this string. ...

PHP Simple dynamic breadcrumb

Hello, I think this script is of big interest to any noob around here :) including me :) What I want to create is a little code that I can use in any file and will generate a breadcrumb like this: If the file is called "website.com/templates/index.php" the breadcrumb should show: Website.com > Templates ^^ link ^^plain tex...

With a ./configure (php) what is the difference between --disable-[name] and --without-[name]?

I want to avoid compiling php with fileinfo, ereg, and parch. What is the difference between --disable and --without with configure? ...

php sql server help needed

Can any one suggest me a good framework for working with SQL Server or Oracle. ...

Unique text field in MySQL and php

I've created a salt using; md5(rand(0,10000000)); (there is probably a better way?) There doesn't seem to be possible to make a text field unique in MYSQL. So how do I check if the salt has already been used for a previous user? Or should I generate the salt based on the current date/time? as it is impossible for 2 users to register at...

Can I make a symfony sfValidatorFile required ONLY if the action is 'new' ?

I have an admin form that lets users create entities that require an image. So in the form class, I have a sfValidatorFile object that sets the 'required' option to true. This is perfect behavior when the user creates a new entity. The problem arises when they edit an existing entity. They shouldn't have to select an image every time the...

PHP upload to GoDaddy hosted site

I'm relatively new to both hosting and PHP, so apologies for (probably) missing the obvious, but… I built a page which would allow file uploads to my site, following the example laid out here: W3Schools PHP upload exercise Through the File Manage on my Godaddy hosting, I created a folder named ’upload’ so that the file would land ther...

How to return Current Object in a Static function in PHP

I neet access to current object in a static method. Code: protected static $name; public static function name($modulename) { self::$name = $modulename; } public function __call($name, $arguments) { $me = new test(self::$name); return $me->$name($arguments); } I want to be able to call method log in Log class. Like this...

how to use control-cache headers?

I downloaded Google speed tracer for Google chrome to see how my site does performance wise and it tells me I need to enable caching for certain files like my style.css, images, etc. I've read that the below php code should tell browsers to cache html content. I wrote a quick php page with a couple of images on it and stuck the below co...

shopping cart software mysql ajax

Hi, I am working on a shopping cart(open cart) software and have this question. I am not familiar with mvc framework. What i want to know how to show content(mysql) inside a div when you click on a link. There will be 8-10 links and clicking on each should fetch its corresponding products. So for example category 1 | category 2 | categ...

Doctrine unsigned validation error storing created_at

Hi, I'm having problems with the Timestampable functionality in Doctrine 1.2.2. The error I get on trying to save() my Record is: Uncaught exception 'Doctrine_Validator_Exception' with message 'Validation failed in class XXX 1 field had validation error: * 1 validator failed on created_at (unsigned) ' in ... I've created the relev...

PHP: Shorten URL by cutting it from the center?

Hello, i've seen in many forums that they cut the url from the center and add 3 dots if it's long in order to shorten it. Example: http://stackoverflow.com/questions/1899537/ajaxify-multipart-encoded-form-upload-forms ---Will be---> http://stackoverflow.c...ed-form-upload-forms How to do that using pure php? Thank you ...

Regex to exclude 1 word out of a regex code.

I need a regex expert to help out on this one. Examples I've found on here and the net I cant seem to get right. I'm using PHP and I have the following regex expression /([^a-zA-Z0-9])GC([A-Z0-9]+)/ This matches items like GCABCD GC123A, etc. What i need to do is EXCLUDE GCSTATS from this. So basically I want it to work just as it...