Solved

XAMPP throws MySQL error when submitting a PHP form

Posted on 2013-12-06
5
771 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
5 Comments
 
LVL 30

Assisted Solution

by:Marco Gasi
Marco Gasi earned 210 total points
Comment Utility
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 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 80 total points
Comment Utility
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 108

Accepted Solution

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PHP and Soap 3 26
Why does this login script not work on a live server? 19 38
PHP string issue 5 16
Codiing Non-Existent Links 4 21
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now