Solved

XAMPP throws MySQL error when submitting a PHP form

Posted on 2013-12-06
5
831 Views
Last Modified: 2013-12-09
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
Comment
Question by:cdesk458
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 31

Assisted Solution

by:Marco Gasi
Marco Gasi earned 210 total points
ID: 39702748
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
 
LVL 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 80 total points
ID: 39702769
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
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 210 total points
ID: 39702974
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
 

Author Comment

by:cdesk458
ID: 39705245
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question