php

PHP - Too many mysql_query("SELECT .. ") .. ?

Hey, I'm making an e-shop and to display the tree of categories and all the products with their multiple variations of prices I made like more than 150 mysql_query("SELECT ..."); queries on one page. (If I count the "while" loops). Is it too many, and if yes, can it have any negative effect? (ofc. it takes longer to load the data ..) A...

Trying to send an array from jquery to PHP function

I'm loading an array in my javascript. I need to send this array, in some format, to the PHP script that I'm going to call. In my example below, gSelectedMeds is my array. The value "count" will tell the PHP script how many "meds" items to expect to receive. I'm having trouble getting the data from the array into an format that I can sen...

Anatomy of a Distributed System in PHP

I've a problem which is giving me some hard time trying to figure it out the ideal solution and, to better explain it, I'm going to expose my scenario here. I've a server that will receive orders from several clients. Each client will submit a set of recurring tasks that should be executed at some specified intervals, eg.: cl...

Determine whether a checkbox is checked upon form submission

Hi, i have been looking for this script for a while now. I have some rules and then i have a checkbox to click if you agree the terms and rules. Now how do i make a check in PHP if the person has checked that box and agreed to the rules? Thanks for ur help, i appreciate it! ...

Getting MySQL error 1064 when performing an INSERT query

What I'm doing is grabbing a feed and inserting the data from each of the feed items. Please see below for the code I'm using. Ok. So I run the page with the query, it loads the feed in to simplexml and I insert the first two items in the feed however I get an error when it gets to the third item. See below for the error I'm getting. I'...

PHP Reference behavior in VARIABLES and CLASSES (that are formed by reference)- are they different or the same?

In PHP, reference variables modify both when 1 or the other is changed. New classes are formed by implicit references, but modifying the extension does not modify the parent. Is this by PHP's design, or are they different kinds of "references?" ...

PHP: How do i test the time which it takes to do a query?

Hey How do i test the speed of a database call from PHP? I interested in testing how many miliseconds it takes my script to call the database with a query and gets the result. For example how many milisecond would the query below take to execute: SELECT * FROM customers OrderBy customer_id Thanks in advance. ...

Randomly selecting rows with MYSQL

hi I have a question, to randomly select records from one table do i have to always set a temporary variable in php or what? I basically need some help with selecting random rows with a model in codeigniter and displaying 3 different ones in a view everytime my homepage is viewed. Anythoughts? ...

Fine-grained access control problem - any ideas?

Hi folks, it's my first post, so be gentle! I'm familiar with a whole bunch of ways to authenticate users for the web-based administration application we're developing, and even various techniques to keep tabs on authorisation... However, my question to you is, how would you recommend I implement a fine-grained access control mechanism...

help with a preg_replace regular-expression

Hello all, I'm really confused as to using preg_replace but slowly learning. I need help with the function: $str= preg_replace('#\W\d+#', '\W \d+', $str); The idea is that Im looking for numbers that have letters directly before them with no spaces, ie abc123. (NOT 'abc 123' and NOT '123abc') and how do I simply include a space or...

Facebook Profile Boxes

I am trying to build a profile box for my fbml facebook app. When this code is executed the only thing that is rendered is the provided url, while what should happen is that it uses the content of that url. i think it has something to do with the refreshRefUrl call as it is returning error 1: unknown error. $user = $this->facebook->req...

why php's str_replace mess up the strings with special chars

why php's str_replace and many other string functions mess up the strings with special chars such ('é' 'à' ..) ? and how to fix this problem ? ...

need to speed up my feed parsing and processing PHP

Hi I'm keeping my self busy working on app that gets a feed from twitter search API, then need to extract all the URLs from each status in the feed, and finally since lots of the URLs are shortened I'm checking the response header of each URL to get the real URL it leads to. for a feed of 100 entries this process can be more then a minu...

php function to return SQL results

This is what i have function GetEventsList(){ $result = mysql_query("SELECT * FROM `events`") or trigger_error(mysql_error()); while($row = mysql_fetch_array($result)){ foreach($row AS $key => $value) { $row[$key] = stripslashes($value); } $id = $row['id']; $en = $row['name']; $endt = $row['date']; $push = "<option value=$id>$...

php: equivalent of $_FILES upload?

Hi, I have to send a file to an API. The API documentation provides an example of how to do this through a file upload script ($_FILES). But, I have the files on the same machine, so would like to skip this step and just read in the file directly to save time. How can I read in the file (a video) so that it will work with this code s...

PHP question on how to display data?

How can I accomplish the following. For example lets say I already have a template that checks to see if the user has entered a link if not it will not display the link template if so display the link template? ...

A php if statement with one equal sign...? What does this mean?

I'm attempting to troubleshoot a problem, and need to understand what this if statement is saying: if ($confirmation = $payment_modules->confirmation()) { All the resources I can find only show if statements with double equal signs, not single. Is this one of the shorthand forms of a php if? What is it doing? (If it's actually wron...

Preg_match regex help

Hi there I need a bit of help. Here is the existing preg_match code: preg_match("/(\/)([0-9]+)(\/?)$/", $_SERVER["REQUEST_URI"], $m); which does a good job of detecting the post_id in the following URI string: http://www.example.com/health-and-fitness-tips/999/ I believe that should be enough background. I'm changing the 999, the...

Cannot parse poorly formed XML

I've been trying to parse this feed. If you click on that link, you'll notice that it can't even parse it correctly in the browser. Anyway, my hosting service won't let me use simplexml_load_file, so I've been using cURL to get it then loading the string into the DOM, like this: $dom = new DOMDocument; $dom->loadXML($rawXML); if (!$dom...

Upload image with facebook API

Question: How to upload an image from my webserver to facebook via FB API? I'm writing an application that retrieves images from the user's photo album, makes some modifications (e.g. adding a watermark) then send it back to photo album. The code I use to upload the photo is as follows <?php include_once("api/facebook.php"); include_o...