Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

XAMPP throws MySQL error when submitting a PHP form

Posted on 2013-12-06
5
Medium Priority
?
855 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 31

Assisted Solution

by:Marco Gasi
Marco Gasi earned 840 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 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 320 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 111

Accepted Solution

by:
Ray Paseur earned 840 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

885 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