php

How do I use a MySQL subquery to count the number of rows in a foreign table?

I have two tables, users and reports. Each user has no, one, or multiple reports associated with it, and the reports table has a user_id field. I have the following query, and I need to add to each row a count of how many reports the user has: SELECT * FROM users LIMIT 1, 10 Do I need to use a subquery, and if so, how can I use it ef...

Zend_Search_Lucene range query error

I have set up each document with a date field. (keyword) Values stored in it are in this format; 20100511 Each time I try to perform a ranged query, I get the following error: date:[10000000 TO 20000000] At least one range query boundary term must be non-empty term Anyone got a clue? Update I have gotten this to work progra...

Problems uploading different file types in codeigniter

Below is my script that i'm using to upload different files. All the solutions I've found deal only with multiple image uploads. I am totally stumped for a solution on this. Can someone tell me what it is i'm supposed to be doing to upload different files in the same form? Thanks function do_upload() { $config['upload_path'] = './up...

How get the url of the returned page?

$curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://foo.com'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl, CURLOPT_TIMEOUT, 30); curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9.2) Gecko/20100115 Firefox/3.6"); $p...

Add several fields to MySQL Database

I am fairly new to building sites with PHP and MySQL but am trying to achieve the following: During an online enrollment process, a promoter is able to enroll up to 20 'fighters' for medical testing services. Each fighter's information is stored in SESSION as $_SESSION['FnumAttr'] where num is the number and Attr is the attribute being ...

Is there a config option in PHP to prevent undefined constants from being interpreted as strings?

This is from the php manual: http://us.php.net/manual/en/language.constants.syntax.php If you use an undefined constant, PHP assumes that you mean the name of the constant itself, just as if you called it as a string (CONSTANT vs "CONSTANT"). An error of level E_NOTICE will be issued when this happens. I really don't like this be...

Error headers: ap_headers_output_filter() after putting cache header in htaccess file

Receiving error: [debug] mod_headers.c(663): headers: ap_headers_output_filter() after I included this within the htaccess file: # 6 DAYS <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> Header set Cache-Control "max-age=518400, public" </FilesMatch> # 2 DAYS <FilesMatch "\.(xml|txt)$"> Header set Cache-Control "max-age=172...

Mathematics - Why is Differential Calculus (MVP) in PHP a tabu?

Hi I want to do a Mean-Variance-Optimization (Markowitz) but i never found anything written in php that does this. MVP needs differential calculus. Can it be done in php and why arent there any classes/works from universities? For a webapplication (regarding performance) would another language be the better choice to handle heavy calc...

Mysql INSERT statement saving some queries but not others

Here is a set of queries that are being executed all in succession (via a foreach php loop). Following the query is the mysql_insert_id, supposedly showing a successful query. INSERT INTO item_relationship (table1, item1_ID, table2, item2_ID, notes) VALUES ('df_dimension','2','df_dimension','1',''): inserted ID: 123 INSERT INTO ite...

How facebook extracts the right thumbnail of a link?

Hi, I'm wondering how facebook extracts the right picture of the article from a link? they ignore any icons, ads images, or other not related images, & they gives you the right image? What technique/method they use? because i've tried to extract all images using a php regex but how to find the right one? Thanks ...

WordPress 2.9.2 Infected with SEO worm, blog.theyoungrens.com, I need some advice on getting it fixed.

I have been trying to get rid of an infection in this (blog.theyoungrens.com) for a few weeks and am at my wits end, I have scoured the DB, and as many source files as possible, to no avail. I have replaced the theme from fresh files, and the blog is fixed for a short amount of time, but inevitably gets re-infected. FTP passwords have a...

Need to integrate phpFox and Wordpress so that there is a single login.

phpFox should take care of user login management, add user and edit user. But would like to automatically create a corresponding Wordpress account when user signs up for phpFox. And when user logs into phpFox user is auto logged into Wordpress so user doesn't really even realize Wordpress login or user account exists. What would be the...

Do you guys know of any good File based caching for PHP?

The data to be cached is going to be HTML files and are to be retained anywhere from 3 days to a week. My understanding is that memcached would not be a good solution here since if the server goes down, we lose everything. Thank You ...

Ruby on Rails or PHP... Somehow uncertain

Hi everybody... I've been thinking about this a long time now but I want to hear your opinion because I always receive the best answers here. So any advance... thank you guys. Right now I have to make this decision: Shift a prototype webservice to production quality. Choose either Ruby or PHP... (Background: A friend of mine is joinin...

Drupal strange problem with third mysql_connect - PHP

Whenever I add a third mysql_connect in the "Body" field the left sidebar disappears. Even if the connection is not used, just set, the sidebar disappears. I've looked at the HTML code from the generated page and in the is changed to . I tried changing the page.tpl.php "div class" to "left" but I still can't get the sidebar to show. ...

Remove line breaks and add BR tags in PHP

I have the following text for which I would like to add a <br> tag between every paragraph. And also remove all the line breaks. How would I do this in PHP? Thanks. So this - This is some text for which I would like to remove the line breaks. And I would also like to place a b> tag after every paragraph. Here is one more paragra...

How to effectively execute this cron job?

I have a table with 200 rows. I'm running a cron job every 10 minutes to perform some kind of insert/update operation on the table. The operation needs to be performed only on 5 rows at a time every time the cron job runs. So in first 10 mins records 1-5 are updated, records 5-10 in the 20th minute and so on. When the cron job runs for ...

How efficient is PHP's substr?

I'm writing a parser in PHP which must be able to handle large in-memory strings, so this is a somewhat important issue. (ie, please don't "premature optimize" flame me, please) How does the substr function work? Does it make a second copy of the string data in memory, or does it reference the original? Should I worry about calling, for...

rawurl encode problem

hi, i am using rawurlencode($url_variable) while passing to a script.. when i receive the variable in the script ,before passing this variable to mysql ,i was doing mysql_real_escape_string . now the problem is like when there is a variable like $url_variable = "Off-St.Mark's-Road" ...after i do mysql_real_escape_string it become sl...

Connecting to Teradata via PHP

We need to access a Teradata database via php application We don't have odbc (unixodbc etc) on the server. How might one go about connecting to a teradata database quickly. Keep in mind - this app needs to be as portable as possible. ...