nate789654 Posted February 2, 2012 Share Posted February 2, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/256246-problem-recreating-error-on-standard-installation-on-xampp-installation/ Share on other sites More sharing options...
trq Posted February 2, 2012 Share Posted February 2, 2012 Define "doesn't work". Quote Link to comment https://forums.phpfreaks.com/topic/256246-problem-recreating-error-on-standard-installation-on-xampp-installation/#findComment-1313641 Share on other sites More sharing options...
nate789654 Posted February 2, 2012 Author Share Posted February 2, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/256246-problem-recreating-error-on-standard-installation-on-xampp-installation/#findComment-1313642 Share on other sites More sharing options...
trq Posted February 2, 2012 Share Posted February 2, 2012 Where is $q defined? Quote Link to comment https://forums.phpfreaks.com/topic/256246-problem-recreating-error-on-standard-installation-on-xampp-installation/#findComment-1313644 Share on other sites More sharing options...
nate789654 Posted February 2, 2012 Author Share Posted February 2, 2012 $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; } Quote Link to comment https://forums.phpfreaks.com/topic/256246-problem-recreating-error-on-standard-installation-on-xampp-installation/#findComment-1313645 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.