php

Command line formatter for PHP and Javascript

Are there any command line (not interactive, not web-based) tools that will reformat (pretty-print) PHP and Javascript code? ...

DELETE from mysql table WHERE column equals value AND column2 equals value2

Having some trouble getting this query to work correctly. mysql_query("DELETE FROM `table` WHERE `id` = '$id' AND 'username' = '$username' "); tried replacing variables with actual data and running it in phpmyadmin to no success any thoughts? ...

To select the newest 3 questions from PostgreSQL by PHP

How can you select the titles of the newest 3 questions from PostgreSQL database by PHP? My attempt in PHP $result = pg_prepare($dbconn, "query1", "SELECT title FROM questions ORDER BY was_sent_at_time WHERE question_id = $1;"); $result = pg_execute($dbconn, "query1", array(7, 1, 9); // Problem HERE, since I do not kn...

To generate a question for a given user in PostgreSQL by PHP

I have a list of URLs in my homepage which is like SO in the following form <a href="?questions&questions=777">link1</a> <a href="?questions&questions=666">link2</a> The following PHP script has a problem in the parameter of $_GET. $dbconn = pg_connect("host=localhost port=5432 dbname=masi user=masi password=123"); // A QUESTION SE...

Is there any way to tell user how many rows are in a table?

Let's say I have a table full of names and I want users to know how many names are there. What would be the output process be? ...

performance of my application using wampserver

I have developed an application using php, mysql and xajax. I always used to test on a setup of which I had installed all applications seperately (apache, php and mysql) and my application was fast (by this I mean that the responsetime of useraction were very low). I recently removed apache, php and mysql and installed wampserver. From ...

Is there a way to search all file names in a PHP project in Eclipse?

I'm using Eclipse PDT for PHP. Let's say I have an error in "rightsManager.php on line 145", and I have hundreds of files in dozens of directories in my project, what is the fastest way to go to that file and line number? I can search through the text of all files with CTRL-H but how do I quickly search through the file names? (like CT...

Domain masking/pointing to a directory of a web application?

I built a LAMP web application that let's users create their own profile page where they can upload their resume and portfolio. The url for a person's profile will be something like http://jobbank.com/user/johndoe John Doe registers the domain name http://johndoefreelancer.com and he wants it to point to http://jobbank.com/user/johndo...

Decrypt BlowfishEasy encrypted file in PHP

I am trying to figure out how to decrypt a file that is encrypted with BlowfishJ.BlowfishEasy. Anyone who has Java and PHP experience and would be willing to help would be great! BlowfishEasy Class: https://opensource.at.northwestern.edu/trac/filebridge/browser/tags/1.0.2/source/encryption-src/BlowfishJ/BlowfishEasy.java Decrypt Call C...

Using PHP Filter function to validate, but ignore empty non-required fields

I want to use the PHP Filter functions to quickly filter a form and show feedback to the user. Some of the fields in my form are required, some are not. I am going to use filter_input_array() to filter all my fields. I will pass the data through in multiple runs. In this way, I will be able to display multiple error messages. I have on...

Check picture file type and size before file upload in php

I have the following code: $filecheck = basename($_FILES['imagefile']['name']); $ext = substr($filecheck, strrpos($filecheck, '.') + 1); if (($ext == "jpg" || $ext == "gif" || $ext == "png") && ($_FILES["imagefile"]["type"] == "image/jpeg" || $_FILES["imagefile"]["type"] == "image/gif" || $_FILES["imagefile"]["type"] == "image/png")...

Using Zend Framework w/o installing it in server root?

I am trying to use Zend's Gbase library, but I cannot figure out how to do so without actually installing it in the PHP path. The complication comes from wanting to make a module for Drupal that is not constrained by the server it is installed on, but can access the library by having it installed in a subfolder of the module. Does anyo...

How do I work with collections of objects? Or rather, does an object retrieve a collection of similar objects?

Hi. I think I get the OOP paradigm at its basic level but I'm having a hard time conceptualizing the proper way to lookup records in a database. I suspect this is because I don't really get OOP as much as I think I do... The application I'm trying to write is a shopping cart because it has a lot of good candidates for objects. The obje...

How to avoid deprecation warning by replacing session_unregister with $SESSION[]?

I just installed PHP 5.3 and am weeding out consequent "deprecated" warnings. It says session_unregister() is deprecated in: session_unregister($serverWideUniqueIdCode); and the replacement seems to be $_SESSION[]. So what would be the syntax with $_SESSION[] to express the same thing? ...

To sanitize all user's input in PostgreSQL by PHP

This question is based on this thread. Do you need the explicit sanitizing when you use pg_prepare? I feel that pg_prepare sanitizes the user's input automatically such that we do not need this $question_id = filter_input(INPUT_GET, 'questions', FILTER_SANITIZE_NUMBER_INT); Context where I use Postgres $result = pg_prepare($dbco...

Variable functions with namespaces in PHP

Hey all, I'm wondering if there is a way to call variable functions with namespaces. Basically I'm trying to parse tags and send them to template functions so they can render html` Here's an Example: (I'm using PHP 5.3) // Main php file require_once 'template.php'; foreach (array("javascript","script","css") as $tag) { echo templ...

How to search with a regular expression in Eclipse?

How can I use Eclipse to search all files which have this on their first line: <? instead of this: <?php The following isn't working: ...

Help with a regex that strips out leading white space.

I am modifying a core function of the Kohana library, the text::auto_p() function. The function describes itself as "nl2br() on steroids". Essentially, it provides <br /> single line breaks, but double line breaks are surrounded with the <p> tags. The limitation I have found with it is that it will but <br />s in a <pre> element. This ...

To understand PHP's header()

Where do you use the command header()? I have the following code at handlers/handle_login.php. The user has gone to the site from index.php which is the starting place. if(!$logged_in){ header("Location: index.php"); die("You are not logged_in"); } ...

How Do I Build My First PHP Extension in C on Linux GCC?

I haven't used C since the 1980s and 1990s with my own experimentation. I'd like to be able to pick it up again, but this time by building small things in it and then loading it into PHP on Linux. Does anyone have a very short tutorial for me to make a foo() function in C as a shared object extension loaded in a php.ini? I assume I'll n...