php

What is the best way to make files live using subversion on a production server?

Currently I have subversion set up so that when I make changes in Eclipse PDT, I can commit the changes and they will be saved in /home/administrator/Project File. This file has the /branches /tags and /trunk directories recommended by subversion. I have no problem properly uploading files to the repository, but do I have to "mv" the f...

Link to unless current -- possible in CI?

In Ruby (forgive me for mentioning it's name), I noticed you could do a anchor link with "link to unless current", which would remove the link if it was the current page. I know there's nothing built into CI to do something similar, but I'm trying to come up with the best way to do this. I've got a few options, but they're all too long...

MySQL data modeling.

I have this current problem with data i have to represent in a MySQL database: I have to support different kinds of products with different data each one, for example, cars, hotel rooms, books, etc. For my application there is some data which is common for each product, like name, description, price, etc. So I think of having a produc...

How do I grab the top result of a Google search?

In a PHP script I want to get just the URL of the top result of a Google search and redirect to it. I could scrape it but is there a better way? ...

php Echo/printing a multiline string?

i have a php file launching my exe. the exe does cout and the text is printed in html which is all fine. until i write "someline\n"; The \n breaks the output and i only see the last line. How do i print/echo text/strings that has multilines in them? The current paste has \n commented out and my text prints fine. It looks ugly in the con...

Debugging hung php

I have a php web application that is occasionally hanging. When I navigate to the page it will just sit there trying to load for hours, even though max execution is 210. This is an application uses curl behind a proxy to download stuff. Error reporting is set to all, but that dosn't matter since the page is blank and hung. I can not f...

Has anyone developed a PHP based Client for a WCF Service?

Has anyone developed a PHP based Client for a WCF Service? I'm in the process of completing a WCF Service for my work. Only I don't expect the client to be running on the .Net Stack. I expect PHP (LAMP) will be the norm. Are there some obvious pitfalls to avoid? I'm not running with any security (BasicHTTPBinding) ...

Does a native php (5+) function exist that does the following in 1 line?

function array_value_from_key($array,$key) { return !empty($array[$key]) ? $array[$key] : null; } The reason I ask is because I have a class function that returns an array. Instead of having to do $myArray = myClass::giveMeArray(); $myValue = $myArray[$myKey]; I'd like to do something along the lines of $myValue = array_value...

PHP removing a character in a string

Hello, My php is weak and I'm trying to change this string: http://www.site.com/backend.php?/c=crud&m=index&t=care to be: http://www.site.com/backend.php?c=crud&m=index&t=care removing the / after the ? on backend.php. Any ideas on the best way to do this? Thanks! ...

PHP Background Processes

I'm trying to make a PHP script, I have the script finished but it takes like 10 minutes to finish the process it is designed to do. This is not a problem, however I presume I have to keep the page loaded all this time which is annoying. Can I have it so that I start the process and then come back 10mins later and just view the log file ...

The best way to read larges files in PHP?

Hi, I have to read CSV files line by line wich can be 10 to 20 Meg. file() is useless ;-) and I have to find the quickiest way. I have try with fgets(), wich run fine, but I don't know if it read a small block each time I call it, or if it cache a bigger one and optimize file I/O. Do I have to try the fread() way, parsing EOL by mysel...

mysql import csv problem

OK, I have just been reading and trying for the last hour to import a csv file from access into mysql, but I can not get it to do it correctly, no matter what I try. My table is like so: +-----------------+------------- | Field | Type +-----------------+------------- | ARTICLE_NO | varchar(20) | ARTICLE_NAME | varchar...

Randomizing RegEx In PHP

Basically I want to use RegEx to grab stuff in between paragraphs in a document. I think the expression would be: <p>.+?</p> Say it grabs 10 items using this RegEx, I then want PHP to randomly choose one of those and then save it to a variable. Any ideas? ...

Are loops the best way to build a table?

I have to build an HTML table that shows data for users versus pages visited. It seems klunky to use for and/or foreach loops, but I can't think of anything better. I'm using PHP, but I would assume that this is language agnostic. ...

Generating PDFs with PHP

I have a PHP application and a need to generate a PDF with the result of query. The easiest way a found to do this was to use the DOMPDF to generate the PDF for me. So a made a function that generates the HTML for me then a pass this to DOMPDF. In the development and testing enviroment everything was fine but on production enviroment I h...

mod_rewrite, php and the .htaccess file

I'm coding a small CMS to get a better understanding of how they work and to learn some new things about PHP. I have however come across a problem. I want to use mod_rewrite (though if someone has a better solution I'm up for trying it) to produce nice clean URLs, so site.com/index.php?page=2 can instead be site.com/tools By my underst...

PHP "Wrong referrer" error when submitting a mail form

I am pretty new to php, but I am learning! I have a simple form on a client website. I am testing the form and when I click submit, I get the following error: Form Mail Script Wrong referrer (referring site). For security reasons the form can only be used, if the referring page is part of this website. Note for the Admin: Please add t...

Empty string in not-null column in MySQL?

I used to use the standard mysql_connect(), mysql_query(), etc statements for doing MySQL stuff from PHP. Lately I've been switching over to using the wonderful MDB2 class. Along with it, I'm using prepared statements, so I don't have to worry about escaping my input and SQL injection attacks. However, there's one problem I'm running in...

What's the best database framework for PHP?

After graduating from calling the mysql_* functions directly in my code, I've stepped up to a home-brewed database abstraction class. Now, I'm beginning to think that I should really use a "professional" DB class instead. I know there are a lot of them out there (ADODB, PDO, MDB2, etc) but I want to know which one I should try out. What...

How do you know the correct path to use in a PHP require_once() statement

As many do I have a config.php file in the root of a web app that I want to include in almost every other php file. So most of them have a line like: require_once("config.php"); or sometimes require_once("../config.php"); or even require_once("../../config.php"); But I never get it right the first time. I can't figure out what...