php

mod_rewrite error 404 if .php

I rewrite my urls to be user friendly. For example I have a page called user.php that I rewrite to /user. But a user can still use user.php. Can I redirect to a 404 if they request a page with a .php extension? Options -MultiViews +FollowSymlinks -Indexes RewriteEngine on RewriteRule ^user/([0-9]+)$ user.php?id=$1 [L,QSA] Thanks. ...

Dates in SQL Server consistently off by 12 hours

Our production platform technologies are these: PHP, MS SQL Sever, and IIS. PHP is set to the timezone 'Pacific/Auckland' which is current +12:00 GMT/UTC. When we retrieve dates from SQL Server, they are consistently 12 hours 'behind' what they should be, ie. SQL Server is storing and serving them as GMT dates, even though the time zon...

stri_replace messing up characters

Hey I am getting a page via curl with this code: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $message = curl_exec($ch); curl_close($ch); I now want to make some replacements to the code in $message, but before that I dump the code ...

how to define variable from mysql output

I have the following variable which returns my URL as needed. But i need to run str_replace() on it to replace a character before echoing it into my HTML code. $url = str_replace("%3A", ":", " . nl2br( $row['url']) . "); As it stands the " . nl2br( $row['url']) . " contains %3A instead of the colon in the URL and for some reason its r...

PHP Session with an Incomplete Object

I'm getting an error I don't know how to fix so I wondering if I could get some help. This is the error Fatal error: process_form() [<a href='function.process-form'>function.process-form</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition &quot;Template&quot; ...

str_replace

$tag = mysql_real_escape_string($_GET['tag']); $tag = str_replace("-", " ", $_GET['tag']); $query = mysql_query("SELECT * FROM tags WHERE name = '$tag'"); $row = mysql_fetch_assoc($query); if (!mysql_num_rows($query)) exit('That tag dont exist.'); I have a tag with spaces in its name, how should i do to replace the spaces with hyphen...

Ajax/Flash file uploads with a progress bar?

I'm looking for a simple solution that will be: Easy to integrate Allow multiple file uploads Show a progress bar while the file is being uploaded Any ideas? I've tried Swfupload and its a real pain to integrate. ...

How to avoid call-time pass-by-reference deprecated error in PHP?

I'm trying to reduce the warnings that are sent to my apache server log. One warning is: Call-time pass-by-reference has been deprecated. It is hard for me to imagine why this was deprecated since it is such a useful programming feature, basically I do this: public function takeScriptsWithMarker(&$lines, $marker) { ... } and I c...

PHP function efficiencies

Hi, Is there a table of how much "work" it takes to execute a given function in PHP? I'm not a compsci major, so I don't have maybe the formal background to know that "oh yeah, strings take longer to work with than integers" or anything like that. Are all steps/lines in a program created equal? I just don't even know where to start rese...

Help with Join

I need help with a join I think. Can't figure it out. I have these tables: Posts `id` int(10) unsigned NOT NULL, `title` varchar(140) DEFAULT NULL, `text` text COLLATE utf8_unicode_ci Posts tags `post_id` int(10) unsigned NOT NULL, `tag_id` int(10) unsigned NOT NULL Tags `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varc...

PHP/GD, how to copy a circle from one image to another?

Is there a reasonably straightforward way to copy a circular area from one image resource to another? Something like imagecopymerge except with circles or ovals etc? If possible, I want to avoid having to use pre-created image files (any oval shape should be possible), and if there's transparency colours involved they should naturally le...

Drupal Session User id for independent script

Hello, I am creating a simple script say a.php. I know that drupal 6 creates a session etc. So in my a.php I am trying to print_r($_SESSION); but that doesnt seem to work. What is the best way to get the logged in users userid in my program? Sorry I am new to drupal. Thank you for your time. ...

`&quot;` not becoming quotation mark when output

My quotation marks, when converted to &quot; by htmlentities() are not turning back into actual quotation marks when output after being stored in the [Postgres] database. Please help - this is time sensitive. ...

Access speed to the fixation value in PHP

Are direct access and constant function which high-speed?( or less memory , cpu) define("FOO","VAL"); print FOO; print constant(FOO); Could you give me a sample cord and the reason , so I am happy. edit: I'm sorry Misunderstood it very much print FOO or print constant(FOO) Which is high-speed? ...

GZIP compression in PHP

Hi! I have a php script that backup my table in .sql format and I want to save the file in gzip format using PHP. How can I do that. ...

"How to get the Google video's thumbnail image ? " in PHP or Javascript ?

I want to use the thumbnail of the Google video's. In PHP or JavaScript function function getScreen( url, size ) { if(url === null){ return ""; } size = (size === null) ? "big" : size; var vid; var results; results = url.match("[\?&]v=([^&#]*)"); vid = ( results === null ) ? url : results[1]; if(size == "small"){ return "htt...

Suggestions for backing up php site and mysql db

Hi, do you have any good suggestions how to backup remote php site and mysql, and upload it to another remote ftp? I do have shell access and it is linux system. Kind of lame question when I post it like that, but I assume some script would have to be run on remote server with site, that would do this. If you don't mind sharing your i...

Ajax Paging in php

Hi friend, I just want the paging like the google adsense. Means paging using the ajax.. How could i do this.? Please send me reference if any Thanks. ...

table back-up either in CSV or SQL Format incomplete.

I have that script that downloads all the contents of my table in sql format and save a local copy. My problem is the content of my table is so huge, the actual data is about 50MB and the data being generated of my script is just 3.5MB. What's wrong with my script? why all data are not written in sql file? $table = "Downloads"; $resul...

Rounded Corners

Hello, I am wondering whats the best way to programmatically make rounded corners for images. This can be either using PHP or javascript. An algorithm will also do for the same and I can code it with Image::Magick or GD. Thank you for your time. ...