php

Fetch location of MySQL slow query log via PHP

How can I discover the filesystem location of the slow query log from php? I'd like to do this dynamically through a query (if possible, or some other runtime method) as opposed to parsing any my.ini files. ...

PHP torrent tracker configuration

Hi everybody. First i'd like to apologize for my english. I'm from Argentina, and i'm not a good english speaker. I'm trying to improve performance in a torrent tracker site, here in Argentina (http://www.trackerx.com.ar). But i've been running with some troubles. It has started to work real slow, and hung up from time to time. I want ...

Call to a member function X on a non-object in Y on line Z

<?php class Conversor { function toLowerFirst($word) { $word = 'test'; return $word; } } class Test { function test() { $word = 'Test'; $word = $this->conversor->toLowerFirst($word); echo $word; } } class Launcher { function launch() { $Test = new Test(); $Test->conversor = new Conversor(); $Test->test(); } } $la...

MPTT ( Modified Preorder Tree Traversal) issue in PHP

Hi guys, My first post here! Seems like this is the place to get wise ;) I am currently in the middle of some testing with my first ever attempt to try the MPTT (Modified Preorder Tree Traversal) approach to storing data in my Mysql database with the help of PHP. However, I am trying to find out the most performance-oriented way to ge...

Storing Sessions in DB Table Not Working (using Zend_Session_SaveHandler_DbTable)

This is my table: CREATE TABLE `Sessions` ( `id` varchar(32) NOT NULL, `modified` int(11) default NULL, `lifetime` int(11) default NULL, `data` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB This is in my bootstrap: $sessionConfig = array( 'name' => 'Sessions', //table name as per Zend_Db_Table 'primary' => 'id', ...

Eliminating duplicate values using PHP

How can I eliminate duplicate in an array using PHP, array looks like below [1] => Array ( [name] => Dean [s_id] => 1 [surname] => [id_nr] => 84934568321 [student_nr] => 0 [createdate] => 0000-00-00 [enddate] => 0000-00-00 [count_abs...

Updating Twitter Status

I'm trying to add some twitter funcionality to my website (php). I publish links like http://twitter.com/home?status=Hello World When the twitter page loads, the text box appears with the text Hello%20World That is, with the text url-encoded. I suppose that it's related with the encoding of the page (actually, windows-1252) b...

Error when trying to insert date into datetime column

Hi there, I have a form that is trying to insert some data into an SQL Server 2008 database. The form has a function to get the current date/time and then insert it into the database as follows; $now = date("Y-m-d H:i:s"); $q = "INSERT INTO ".TBL_USERS." ( username, password, userid, userlevel, email, created, updated, timestamp, fulln...

Why is the result of E_ALL | E_STRICT the same as only E_ALL?

In PHP error reporting, E_ALL equals 8191 (1111111111111) E_STRICT equals 2048 (100000000000) Using bitwise OR to combine them: 1111111111111 100000000000 we still get: 1111111111111 Why is the result of E_ALL | E_STRICT the same as E_ALL? How does error_reporting() function distinguish between E_ALL | E_STRICT and E_ALL? ...

Gettext, not displaying

I'm trying to load my .mo translations using the following code, but it doesn't work. I have the php gettext ext. enabled in my phpinfo() and all the required locales are installed. Did I miss anything? $locale = "en_US"; putenv("LC_ALL=$locale"); setlocale(LC_ALL, $locale); bindtextdomain("messages", "./locale"); textdomain("message...

PHP find element key

i have this array Array ( [0] => a [1] => b [2] => c [3] => d ) how can i get an element's key?(for example a=0,c=2) ...

Web development: Should I learn PHP?

I am a student at university and I want to get in touch with web development. But I don't know which language I should learn. I have a strong C++ and Java background. I tried JavaEE but it's difficult to host JavaEE Projects. Almost all server hosters run PHP, (python, perl). I would like to start with PHP. The Question is : Should i s...

Triggering jQuery functions with PHP

Hey, So far during my site development I have been storing all my jQuery functions in an external .js file, below are two examples of the functions inside: // Loads the login form into the page. function loadLoginForm() { $('[name=loadLoginForm]').click(function() { $("#loadingImage").css({ display:"block" }); $("#mainWrap")....

Optimizing Mysql Query

What is the general "best practice" for this type of functionality. I have a table of users a table of polls and a table of poll responses on a website. I want to load a page that loads a poll that a user hasn't yet answer. What is the most efficient and "best" way of going about this. Things I've tried that seems slow/not optimal: ...

how can you read from database and write to the http stream. php & mysql

Hi, It is like continue getting data from mysql using PHP and simultaneously stream out to the http. Like in java we can write into ServletOutput stream? The size of the data can be like 200 MB. Thanks ...

Get current auto_increment value

I am doing mysql insert for my table using php. Autoincrement column name is "link_id" and "alias" colum is used to make SEO friendly url. During my insert, I would like to attach link_id value at the end of my alias column. So I need to know what is the being inserted link_id value. I do not want to do another query. mysql_insert_id...

set file permissions in header before forced download in php?

Im generating a file to present to the user for download, but the server isnt letting me open it, because it needs to have permissions of 777 before it can do so. Here is my code $fh = fopen("$name", 'w') or die("can't open file"); fwrite($fh, $data); fclose($fh); header("Cache-Control: public"); header("Content-Description: File Tran...

What are best practices for determining if I should create a new Drupal module?

I'm using Drupal for the first time for a project at work. I'm finally getting my head wrapped around some of the core concepts, but when it comes to customizing output I'm unsure of how to proceed. I have to build a fairly specialized image gallery. I've managed to cobble something workable together using Views2, but it's not quite whe...

Can anyone find the error in this POST NSMutableURLRequest to a PHP script?

I try to send data to this php script: mb_internal_encoding("UTF-8"); if(isset($_POST['format']) && isset($_POST['category']) && isset($_POST['title']) && isset($_POST['description']) && isset($_FILES['photo']) { save($_POST['category'], $_POST['title'], $_POST['description'], $_FILES['photo']); } else { echo "There...

PHP: get next 13 dates from date?

I am trying to get an array of a date plus the next 13 dates to get a 14 day schedule starting from a given date. here is my function: $time = strtotime($s_row['schedule_start_date']); // 20091030 $day = 60*60*24; for($i = 0; $i<14; $i++) { $the_time = $time+($day*$i); $date = date('Y-m-d',$the_time); array_push($dates,$dat...