php

Development, Staging environments, and more - questions !! :(

Hello, Here's my story, Sort of long - please bear with me :) I am currently the only programmer here, no much designing to do - yet. When I started, we had no source control, - files where edited directly from a "development" server - which used rsync to sync to production servers. I have not had much experience doing this kinds of...

mySQL - Using data from another table.field to determine results in a query.

Hello Hello, Buried in mySQL syntax and query structure problems once more. I'm currently doing this query fine:- SELECT DATE_FORMAT(`when`, '%e/%c/%Y')date , COUNT(`ip`) AddressCount FROM `metrics` WHERE `projID` = '$projID' GROUP BY DATE(`when`) This works fine to find the specific number of ip address's hit. However, what...

MySQL: Why is it ignoring the text in the form field?

I am trying to teach myself MySQL/PHP from the very beginning. The following code was lifted from various tutorial sites. I'm using phpMyAdmin provided by my webhost. I made a table with an auto-incrementing field called "ID" and another field called "first" (varchar, limit 30, not null). Then I made a simple form with one text field na...

Creating your own TinyURL

Hello all, I have just found this great tutorial as it is something that I need. However, after having a look, it seems that this might be inefficient. The way it works is, first generate a unique key then check if it exists in the database to make sure it really is unique. However, the larger the database gets the slower the function ...

How to find memory used by an object in PHP? (sizeof)

How to find memory used by an object in PHP? (c's sizeof). The object I want to find out about is a dictionary with strings and ints in it so it makes it hard to calculate it manually. Also string in php can be of varied length depending on encoding (utf8 etc) correct? ...

Running PHP Zend Test in Eclipse

Is it possible to run PHP Zend test cases (those that extend Zend_Test_PHPUnit_ControllerTestCase, etc.) through Eclipse PDT? I would like to be able to run them in a similar fashion as you run JUnit tests in Eclipse, by right-clicking the test file and selecting "Run as a JUnit test case." I'd love to see the green or red bar instead...

PHP--parsing multipart form data

I'm trying to put together a HTML POST-ed form that has two fields--a file upload, and a text field. Since the form has a type multipart/form-data for the file upload, I can't get at the text field through the normal PHP $_POST variable. So how can I get at the text field in the form with PHP? As per requested, here's some code, basic...

PHP : can't use method return value in write context

I would think the following piece of code should work, but it doesn't: if (!empty($r->getError())) Where getError() is simply public function getError() { return $this->error; } Yet I end up with this error: can't use method return value in write context What does this means? Isn't this just a read? Thanks in advance! ...

Automated way of finding where in the codebase a function is used in PHP

I'm trying to find automated way of finding where in the code a function is used. Some form of autogenerated documentation where I have Class->method is used in this files: a.php , b.php etc. I am tryng to find something out there to prevent rolling my own. We currently have no automated documentation system so anything goes. ...

Php - troubles with files paths

Hello, i can't understand one thing. In code, for example: $filePath = 'http://wwww.server.com/file.flv'; if( file_exist($filePath) ) { echo 'yes'; } else { echo 'no'; } Why does script return 'no', but when i copy that link to the browser it downloads? ...

JavaScript equivalent of PHP's strpbrk function?

Hi, In PHP, I can use the strpbrk function to determine if a certain string contains a certain set of characters. Is there a way to do that in JavaScript? TIA. Edit: for those who may know JS but not PHP, strpbrk takes an input string and a string containing what you want to match as its arguments, and returns a string starting from ...

facebook ease effect w/ jquery

Hi, Can anyone recommend how to go about creating the "ease down" effect facebook implements today when you AJAX-load updates in your news feed? (When it reads "load x new news feed articles") if I use prepend, the new updates will be inserted all at once. I'm looking for a way to ease/slide down the old updates smoothly in order to ma...

How do I create unique IDs, like YouTube?

I've always wondered how and why they do this...an example: http://youtube.com/watch?v=DnAMjq0haic How are these IDs generated such that there are no duplicates, and what advantage does this have over having a simple auto incrementing numeric ID? How do one keep it short but still keep it's uniqueness? The string uniqid creates are pre...

how to put header authentication into a form using php?

Hey guys, for the page I am doing needs a login authentication using Twitter (using tweetphp API). For test purposes I used this code below to do a successful login: if (!isset($_SERVER['PHP_AUTH_USER'])){ header('WWW-Authenticate: Basic realm="Enter your Twitter username and password:"'); header('HTTP/1.0 401 Unauthorized'); echo ...

Default absolute path to grep in Linux kernel 2.6.18-128.1.10.el5

There was a recent change on the server I do most of my work on and all PHP exec()'s now need absolute paths. Its faster than asking IT to ask it here. So, does anyone know where grep is by default? ...

PHP and SQL Parsing

Say I have an array of table DDL queries and I want to get the name of each table being created. What would the best approach be for extracting the table name? So for example: $ddl = array( 'CREATE TABLE tableOne ...', 'CREATE TABLE tableTwo ...', 'CREATE TABLE tableThree ...' ); foreach($ddl as $tableDef) { $tableName...

capture part of a string with regex using PHP?

I can't seem to find a function that captures and returns a regex'ed string. $string = "hello123!"; $string = regexfunction($string, "/([0-9]*)/"); echo $string; Prints 123 ...

Am I using the PHP.js strpbrk function properly?

Hi, I have the following JS function: function validatePass() { var oldPass = document.getElementById("oldpass").value; var newPass1 = document.getElementById("newpass1").value; var newPass2 = document.getElementById("newpass2").value; if(strpbrk(newPass1,"abcdefghijklmnopqrstuvwxyz") != false) { document.getElementById("Contain...

What's the best way of displaying fields on screen after a user posts a form, without going back to the db?

I have 3 arrays of data that are used to populate some fields on screen. When a user posts the form (unrelated to the data contained in the arrays) I want to display the array data on screen again, but without retrieving it from the database when the page reloads. What's the best way to temporarily store these values? I was thinking of...

Problem creating a table using php..

Hello I am trying to create a table in MySql using php. My code looks like this: $sql = "CREATE TABLE qotwQuestion1111 ( QuestionId int PRIMARY KEY AUTOINCREMENT, Question varchar(5000), MemberId varchar(255) FOREIGN KEY REFERENCES qotwMember(MemberId), PostDate date, Vote int )"; mysql_query($sql,$con); i am unable to create this tab...