Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

XAMPP throws MySQL error when submitting a PHP form

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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
The viewer will learn how to count occurrences of each item in an array.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

722 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