Hi,
I'm diligently plugging away at some code that checks for divisibility (yes, it's to generate primes) and I want to know how to stop a for... loop if the condition is met once. Code like this:
$delete = array();
foreach ($testarray as $v) {
for ($b=2; $b<$v; $b++) {
if ($v%$b == 0) {
$delete []= $v;
}
}
So $testarray is int...
methods like mysql_fetch_array move the internal resource pointer on a MySql result set, but how do you get the current value of the internal resource pointer though? Is there a "mysql_" method that returns this value?
...
So I have an item class as follows:
class Item
{
private $db;
private $data = array(
'AltItem1' => null,
'AltItem2' => null,
'BaseUOM' => null,
'Category1' => null,
'Category2' => null,
'Category3' => null,
'Category4' => null,
'Iden' => null,
'IsHCS' => null,
'ItemDesc' => nul...
I face the following problem
function book($memberid, $classid){
if (!book){
// update the db and change the book variable to true
}
}
My problem is 2 requests submitted at the same time.
The first request passes the line if (!book){ but not yet update the db. And at the same time, the second request runs the same function and also p...
I am trying to get a web app made on Zend Framework up but am encountering this error
Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/worm/index.php on line 17
Fatal error: require_once() [function.require]: Failed opening required 'Zend/Loader.php' (include_p...
Hi,
I'm currently resizing images in PHP, and my current code takes about 2-2.2 seconds (not including upload time) to resize an image to two sizes, one thumbnail size, and one medium-sized.
Can anyone recommend a framework or class that I could download that would resize the images quickly?
Thanks.
...
I want to know how to capitalize in PHP
...
Hi,
I'm trying to create a very simple message board (author, text, and date written) that will auto-update every few moments to see if a new message has arrived, and if it has, auto load the latest message(s).
I'm proficient in PHP, but my knowledge in AJAX is lacking.
The way I see it, I would have to create a PHP file called get_me...
I have created a widget for my web application. User's getting code and just pasting that code in their website and my widget works on their website something like twitter, digg and other social widgets.
My widget is on the basis of post, for a single post (say postid: 234) I am providing single widget, so anyone can embed the widget on...
With PHP, I'd like to use a preg_replace() filter for passwords such that the only characters available for passwords are US ASCII typable, minus control codes and NULL.
What's the RegEx to achieve that which I can plugin to preg_replace()?
EDIT:
I've been advised to edit this question since I "get it" now and won't be doing this terr...
I am in the early stages of creating a small-medium sized web application by myself. I read "PHP Objects, Patterns, and Practice," and I decided to use page controllers because quick production is a high priority. Page controllers were also appealing because I am unfamiliar with PHP frameworks and creating an elaborate front controller ...
I have two different domains that both point to my homepage in the same server.
I want to log every single access made to my homepage and log which domain the user used to access my homepage, how can I do this?
I tried mod_rewrite in Apache and logging to a MySQL database with PHP but all I could do was infinite loops.
Any ideas?
EDI...
For some reason, when using this code the file it outputs is just called ".jpg".
<?
$title = $GET['title'];
$url = $GET['url'];
$ourFileName = $title.jpg;
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
$ch = curl_init ("http://www.address.com/url=$url");
curl_setopt($ch, CURLOPT_HEADER, 0)...
Hi,
I have the following code:
$link = new PDO("mysql:dbname=$databasename;host=127.0.0.1",$username,$password);
$query = $link->prepare("SELECT * FROM index WHERE sbeid=:idvar");
for($j = 1; $j < count($array); $j++)
{
if($array[$j][16] == "TRUE" || $array[$j][16] == "FALSE")
{
$paramforquery = $array[$j][25];
...
I have an index view that lists items, and it's a long list so I use Paginator to limit items to 50-to-a-view.
Each item has an "edit" link that goes to an edit view with inputs/validations/etc. When that form is submitted, I redirect the use back to the index view.
So far so good, but here's the rub:
If a user is on page N of the in...
I need to create temporary files with PHP for my site. How can I have them numbered in the following manner:
tmp_file_01.jpg
tmp_file_02.jpg
tmp_file_XX.jpg
I'd like to avoid running the shell to figure out what the next available index is.
...
Hey,
I'm not quite sure if this is the right approach, this is my situation:
I'm currently trying to select 15 galleries and then left join it with the user table through the id but I also want to select one random picture from each gallery however from what I know you can't limit the left join (picture) to only pick up one random pict...
I have a simple PHP mailer script that takes values from a form submitted via POST and mails them to me:
<?php
$to = "[email protected]";
$name = $_POST['name'];
$message = $_POST['message'];
$email = $_POST['email'];
$body = "Person $name submitted a message: $message";
$subject = "A message has been submitted";
$headers = 'From: ' ....
I'm working on a project that'll use PEAR packages. Because you never know what version of the PEAR package will be installed on your hosting provider (and especially because I require a patch to have been applied to one of the packages), I'd like to put the PEAR source for my project right into SVN, so other developers can immediately ...
I have click-able images in my html page that call a javascript function... however nobody is clicking on them as they do not look click-able... how can I make them click-able without using an <a href=""></a> tag around it?
Here is an example of my code...
<div id="bvu11" style="margin: 0px 5px; float: left;">
<span id="bviu11">
...