Problem recreating error on standard installation and on XAMPP installation

I’m not sure my title is clear or if I’m in the right area of the forum, sorry.

I have installed Apache 2.2.21, MySQL 5.1.61, phpMyAdmin 3.4.9 and php 5.3.5 separately on one machine and have run into a bug.

This bug is produced by this code:
[php] if ($doSearch) {
$hash = md5($q);

//change code from PHP4 to PHP5 Search::getFromHash obsolete
$searchh = new Search();
if (false === ($search = $searchh->getFromHash($hash))) { // search doesn’t exist
$time_start = microtime(true);

// create the search
if (false === ($search_id = $searchh->create($q))) {
  die("error with search (1)");[/php]

Here is function getFromHash:
[php] function getFromHash($hash) {
global $dbh;

$sth = $dbh->prepare("SELECT * FROM `searches` WHERE `hash` = :hash LIMIT 1");

$sth->bindValue(':hash', $hash);

if ($sth->execute()) {
  if ($sth->rowCount() == 1) {
    return $sth->fetch(PDO::FETCH_ASSOC);
  }
}

return false;

} [/php]
And here is function create:
[php] function create($terms) {
global $dbh;

$hash = md5($terms);

$sth = $dbh->prepare("INSERT INTO `searches` (`hash`, `terms`)
                             VALUES (:hash, :terms)");
$sth->bindValue(':hash', $hash);
$sth->bindValue(':terms', $terms);
if ($sth->execute()) {
	return $dbh->lastInsertId();
}

return false;

} [/php]
However, this code works perfectly on XAMPP 1.7.4 which is using the same version of php 5.3.5.

I have modified the php.ini file so they are the same but I cannot find out why in an XAMPP environment this code works while in a standalone environment is doesn’t.

I should say, I didn’t write this code. I am very new at php and was simply asked to move this system to a new machine.

I would be very grateful for any help in either fixing the bug on the new installation or recreating it on the XAMPP installation so I can have a go at fixing it.

If there is any more info you need let me know.

Sponsor our Newsletter | Privacy Policy | Terms of Service