Jump to content

Recommended Posts

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:

 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)");

 

Here is function getFromHash:

  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;
  } 

 

And here is function create:

  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;
  } 

 

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.

 

Sorry I should have been more clear.

 

It dies when trying to create the search and only displays "error with search (1)".

 

This only happens on the new installation and not on the XAMPP installation.

$q is initially nothing

$q = "";

 

and then is set with

 

if (isset($_GET["q"]) && $_GET["q"] != "") {
$q = $_GET["q"];
  $q_html = htmlspecialchars($q);
  $q_url = urlencode($q);
  $doSearch = true;
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.