php

Overly specific mysql query not working

I have written a query to find similar ids based on tags from a current id, much like amazons, you would also like. The problem is, in my example I want to exclude bookid 30 from this search. Here is my query: note: $similar is basically a string filled with tags built up with a few "like %item% or" $query = "SELECT * FROM books ...

How would I skip optional arguments in a function call?

OK I totally forgot how to skip arguments in PHP. Lets say I have: checkbox_field ( $name, $value = '', $checked = false, $compare = '', $parameter = '' ) How would I call this function and skip the second last argument? checkbox_field('some name', 'some value', FALSE, '' , 'some parameter'); Would the above be correct? I c...

What does this code do? (2)

I don't understand the => part. foreach ($_POST[‘tasks’] as $task_id => $v) { What does it do in a foreach loop? ...

Custom Sessions with Joomla

I've trying to build Joomla into my existing website so I can use it for premium content. I've already got a custom-built authentication system that sets my own session variables. For some reason, Joomla (which is located in a different directory) doesn't want to recognize these session variables, even when adding the session_start()...

Destroying $_SERVER session?

Okay so I'm not using any session variables, rather my code looks like this: if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="Enter your Twitter username and password:"'); header('HTTP/1.0 401 Unauthorized'); echo 'Please enter your Twitter username and password to view your followers.'; ex...

PHP - Create an assoc array with equal keys and values from a regular array

I have an array that looks like $numbers = array('first', 'second', 'third'); I want to have a function that will take this array as input and return an that would look like: array( 'first' => 'first', 'second' => 'second', 'third' => 'third' ) I wonder if it is possible to use array_walk_recursive or something similar... ...

Returning unsigned long long from an extension function in PHP

If i need to return a long i simply use the RETURN_LONG macro. But what do i do if i need to return an unsigned long long. If i use this macro the data gets corrupted... ...

jquery contenteditable linebreak

Hi Guys, I have a content editable area and im trying to disable enter/return and shift enter from creating a new paragraph, i have this working with the script below but it disables the buttoms all together, what i wish to do is have return just place a line break rather then go to a new paragraph. $("#content").keypress(function(e){ ...

Sending Variables for PHP FileSystem Functions with Form Submission

I'm trying to find a secure way to do the following: Users enters value into html form. Form is submitted. PHP uses submitted value as the argument for the "scandir" function. My theory is include logic in the php script that forbids absolute paths and requires the directory name to include a certain value. My concern is that a hack...

Drupal Search Behavior

I looked into the DP 6 search API and did not see a hook that would let me alter the search keys before they are passed into the search module to execute the search. I want to do keyword expansion on the string that the user entered. For instance, if the user entered 'foo', I want to execute a search for 'foo' and 'bar'. There should ul...

using php how can i scrape all fields names and output to a text file?

what i want to try to do is be able to enter say a url onto a variable and once executed the page will scrape all input field names and export it to a text file. for example. if i have <input type="text" name="firstname"> <input type="text" name="lastname"> <select name="sex"> <option>...</option> ... </select> the output would be ...

Push email to a apache/php server

We've built a web service that needs to check constantly for email messages. Basically, an user sends us an email, and the server should make actions based on that email. We could use a crontab PHP script that checks for new messages every minute, with POP. But that's kind of offensive to the popserver and not very efficient (1min is too...

How do I incrementally echo responses to the user while a script is running?

I have an import that needs to notify the user each time an item has been successfully imported into the database. Is there a way to loop, perform some functionality, provide the output message, and then loop through again with the same action? ...

Click on link, add text to textarea?

Let's say I have this javascript: <script language="javascript" type="text/javascript"> function addtext() { var newtext = document.myform.inputtext.value; document.myform.description.value += newtext; } </script> and I want to enable it so I can click on some html link that says "add text" and I want the text to be @ . $usern...

Installing IonCube on IIS7 / Windows Server 2008

Hello, we've inherited a PHP project from a client that requires IonCube. Our boxes all run on IIS7 and although we've followed the instructions for configuring it, it isn't loading the decoder library. Have any of you had any success with getting IonCube up and running on Win 2k8 (32bit)? I'm pulling my hair out over this so any help wo...

My productivity is decreasing as the project becomes larger. How to increase productivity as size of project increases?

I initially started off with a small project, editing php files and such in notepad++. It used to be easy to think of a feature, and add it on as a separate file onto the project. As the project became larger, my productivity began to decrease because I couldn't remember all of the functions I made, and where they were stored etc... Then...

Are there any code libraries that validate/convert blog comments to XHTML strict?

I am working on a website in PHP where people can make comments similar to a blog, and I only want particular tags to be allowed. Are there any pre-built libraries that process comments and produce valid XHTML Strict code? I would need to do this in JavaScript so I can generate a live preview like Stack Overflow, plus in PHP before savin...

ORDER BY date while also using LIMIT in a MySQL query - PHP

HI, I can't quite figure this out, I'm trying to pull records from MySQL, order them reverse-chronologically and limit the results to four per page (and using pagination to organize the pages). It is currently returning this error: Fatal error: SQL in /Users/allan/Sites/4is_site/casestudylist.php on line 126 $limit = 'LIMIT ' .($pag...

Calculate after X days from today

Hi Friends i am develop a webpage in that i need to calculate x days from a specified date , The problem is we exclude the saturday and sunday . For example $Shipdate = '06/30/2009' and the x is 5 means , i want the answer '7' [ie 30 is tuesday so after 5 days it will be sunday , so there is two holiday(saturday and sunday) so ...

Function to escape different variable types in MySQL Query

I got sick of writing queries in my PHP as: "WHERE '" . Database::escape($var) . "'"; The escape() function just calls mysql_real_escape_string() - but it's there so I can extend support to other databases later. Having to single quote strings in the query was making my code more cluttered. So my idea was to create an other function ...