Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 860
  • Last Modified:

XAMPP throws MySQL error when submitting a PHP form

I have a Windows 2008 R2 running XAMPP 1.8.3-1 (with XAMPP Control Panel v3.2.1), with PHP, MySQL, Apache all being in that package.
The website runs smoothly, all looks good except for one thing: we have a "Request Info" page, in which the user fills out a form an it is emailed out. The form is submitted successfully, but this error appear on the screen:
"
Store row failed:
Could not connect to MySQL.
"
Functionally is not affected, it just looks ugly and misleading.
Here's what I did so far:
In php.ini I have:
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
display_errors = Off
http://www.waytocode.com/2011/disable-warning-and-notices-in-xampp-wamp-or-lamp/
http://stackoverflow.com/questions/10160859/turn-php-error-reporting-off-in-xampp
And I've also set error_reporting in similar manner (to now display) in some other files (forgot which).
But still getting this MySQL error. How do I suppress it? Thanks
0
cdesk458
Asked:
cdesk458
3 Solutions
 
Marco GasiFreelancerCommented:
First of all, in developing environment is strongly helpful to have always display_error set to On:

error_reporting(E_ALL);
ini_set('display_error', 'On');

Only in your production environment you can set to Off display_error: suppressing errors, warning and notices always allow to ignore problems which soon or later will raise up.

Secondly, are you saying in other page of the site database connection works fine and in that page it fails? Or other pages don't use database?

Anyway, we need some code to see in order to can help you.

So I pray you to do the following:

1 - set display_error on and error_reporting to E_ALL and report us the output with these settings:
2 - post here the code of the problematic page and the code which can be involved, for instance the code which does the connection to the database if it resides in another file (obviously remmeber to clear sensitive data such as passwords from the code before to post it here)

This way we'll can help you better without having to guess what's going wrong :)
0
 
Dave BaldwinFixer of ProblemsCommented:
You don't suppress it, you fix the code so there's no error.  First, is there supposed to be a connection to MySQL on that page?   Or is it just supposed to send an email?

@marqusG has some good recommendations.
0
 
Ray PaseurCommented:
Store row failed:
Could not connect to MySQL.
These messages are deliberately generated by the script that is the action script for the "request info" page.  They are not PHP messages, so suppressing PHP error_reporting() will not suppress them.  You will need to change the PHP program code.  Here's the path.

Look at the "view source" of the "request info" page.
Find the HTML <form> tag.  In that tag, find the URL of the action= attribute.
Get the PHP source code for that URL.
Make a backup copy of the script before you make any changes.
Examine the PHP script.  Most text editors have a find function that you can use to look for the message strings.
Remove the PHP code that is generating the unwanted messages.  You can usually do this by "commenting out" -- putting two slashes in the beginning of the line of code.
Save your changes, overwriting the original script.
Test and verify that the newly changed script works correctly, or revert to the backup copy.
<?php
echo 'Hello';    /* SENDS BROWSER OUTPUT */
// echo 'World'; /* NO OUTPUT - THIS IS A COMMENT */

Open in new window

0
 
cdesk458Author Commented:
Thanks for the help, the issue is resolved.
Looks like there was this line of PHP that returning FALSE
$ok = $this->insertObject($table->db_table_name, $oRecord, $primaryKey, false);
So an email was being generated, but a record of it also inserted into the db (which is not very important).
Seeing no easy fix/trobleshooting steps, I just commented that code block for now.
It works.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now