php

Difference in efficiency of retrieving all rows in one query, or each row individually?

I have a table in my database that has about 200 rows of data that I need to retrieve. How significant, if at all, is the difference in efficiency when retrieving all of them at once in one query, versus each row individually in separate queries? ...

PHP preg_match question

How can I match the three words in the following string with a Perl compatible regular expression? word1#$word2#$word3 I don't know the actual words "word1, word2 and word3" in advance. I only know the separator, which is #$. And I can't use the word boundary as I have a multibyte encoding. This means for instance that the string can ...

Memcache in high performance sites with PHP

I have been working in trying to optimize a webservice that is required to return somewhat quickly (less than 1 second) and is required to maintain a high load of requests (greater than 1000/second). We are using memcached as a way to store objects "in memory". It seems we are getting a large number of timeout errors from memcache. [Thu...

PHP eval error when assigning value to variable

Hello, all SO users! I have a bit of PHP code (for the module feature of my CMS (not drupal) which allows people to view pages, comments, forum posts, blog posts, etc...): if(isset($_GET["m"])) { //Does the module exist and activated, and has it a function called view? if(isset($module_exists[$_GET["m"]]) && method_exists($_GET...

preg_replace - leaving in unwanted characters

I've got a string: $string = "Hello World!"; I want to turn it into a URL friendly tag, and I've developed a function to do it: function stripJunk($string){ $string = str_replace(" ", "-", $string); $string = preg_replace("/[^a-zA-Z]\s/", "", $string); $string = strtolower($string); return $string; } However, when I...

Why does my preg_replace() on multi-line file contents on Windows fail?

I have a text file Qfile.txt and the contents are follows, and want to create another file with the same informations and but answers are diffrent. Qfile1.txt,Qfile2.txt Qfile.txt Question "What is your age?" Answer "" Question "What you doing?" Answer "" Question "What is you name?" Answer "" Qfile1.txt Question "What is your age...

Multidimensional array only returning one item in PHP

I have a multidimensional array, that is a few levels deep. I am trying to loop through some of the lower levels of array items, but when I do, it seems to only return one of the array items. foreach ($items as $item) { foreach ($item as $id) { echo $id; } } For some reason, echoing $id only returns the first item in the $ite...

How do I pass data between pages in PHP?

So in a nutshell on "page1.php" I have a calculator that consists of an html form, and then the php code totals the input and displays the total price. Below the price, it also displays a link to "page2.php" which contains an html form where they can enter their contact information and upon submitting the form the selections they made on...

how to pick a country dropdown selection form item without using database?

I have this PHP code that I use to make a dropdown form selection of country's I would like to eliminate this extra mysql query though and just store the output like in code to on the page However I am lost on how I would have the users country SELECTED If I do not use the query to get the data Please advice <select name="country" styl...

PHP Classes problem, class not found

I solved this question my own. The filename was wrong lolz. Hello everyone! I'm building a CMS like Drupal and Joomla. I'm working on the module feature (plugins), and I got the following error: Fatal error: Class 'settings' not found in C:\wamp\www\SYSTEM\view.php on line 22 Here is my code: start.php <?php //First of all, start ...

How do I get php-win to work with Zend Server?

I recently installed Zend Server CE but I can't get php-win to do anything. When I run a cmd script using the standard php call it works perfectly but any call using php-win just fails to do anything. No output; nothing. For example: php C:\path\to\script The above works. But the below doesn't do anything: php-win c:\path\to\scrip...

Grabbing the information from a url?

I have an on line project "question of the week"; this project allows the users to submit their questions. These questions are saved in a mysql table; the question is also sent over to another simplepost.php which stores the question in a phpBB. I want to use this phpBB for every question, for discussions on that question. So now, my ...

Strange php if statement problem

if($country == 224 || $country == 223 || $country == 39 && $zip == '' ){ $_SESSION['sess_msg'] = "Please enter a Valid zipcode"; header("location: $SITE_PATH?p=account.profile.name"); exit; } variable value -------- ----- $country 224 $zip 11111 I know that $zip isn't empty, but the code executes as if it i...

PDO: bindParam versus bindValue

What is the difference between bindParam and bindValue for PDO in PHP? http://www.php.net/manual/en/pdostatement.bindparam.php http://www.php.net/manual/en/pdostatement.bindvalue.php ...

php and mysql script timeout with no errors?

Below is my code, it is a script I need to run just 1 time to update a new mysql table I have added, I have 60,000 users and it ran and added 268 rows, it did not show any errors or anything, it just didnt add the rest and I have no idea why? <?PHP require_once "../config/functions.inc.php"; // get users $sql = 'SELECT * FROM fri...

PHP Frameworks - Layout Dynamic Menu

I am developing a website in PHP and I would like to use a mvc framework to do this as I want to gain experience with PHP frameworks. I have looked at Zend, CakePHP, and CodeIgniter and I have not been able to find an intuitive way to accomplish this. What I need to do is create a layout that will be for example: <html> <head> <!--scr...

What is the difference between a language construct and a "built-in" function in PHP?

Hi guys, I know that include, isset, require, print, echo, and some others are not functions but language constructs. Some of these language constructs need parentheses, others don't. require 'file.php'; isset($x); Some have a return value, others do not. print 'foo'; //1 echo 'foo'; //no return value So what is the internal dif...

Oracle Equivalent of MySQL's TEXT type

Does Oracle have an equivalent column type to MySQL's TEXT type? If not, how are larger blobs of text typically stored? BLOB, varchar(32767)? It's Oracle 10 being accessed via PHP, if it matters. Historical context is more than welcome. ...

How can I make a custom exception object evaluate to false in an if condition?

Hey there SO, I was just wondering if there was any way to make my object return false if placed in an if statement. The reason is I'm making a custom exception class. I would like to be able to do something along the lines of class Dog{ public function lookAround() { if(seeDog()) { return bark; ...

SQL Query: Incrementing by two instead of 1

Hello all, I am trying to update a field in a table by increasing its integer value by 1. Here is what I am using: function updateViews($id){ $sql = "UPDATE tweets SET tweet_views = tweet_views + 1 WHERE tweet_key = '$id'"; $result = mysql_query($sql) or die("DB Error : ". mysql_error()); return $result; } However, I find its inc...