473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

mysql error handling

I have written a program which logs to mysql database. Error routines
should handle the worst case if something goes wrong. In my tests I get
a segmentation fault if I stop the mysql database (stopping after the
mysql connection was successfully). It breaks at this line:
iErr=mysql_errno(&f->f_hmysql);
Here the mysql_query call and the code of the error handling:

/* query */
dprintf("try to call mysql_query ...\n");
if(mysql_query(&f->f_hmysql, psz)) {
int iErr=0;
dprintf("in error handler\n");
iErr=mysql_errno(&f->f_hmysql);
dprintf("mysql insert failed. ErrNo: %n\n", iErr);
}
else {
dprintf("db insert sucessfully\n");
}
dprintf("...after mysql_query.\n");

Any idea how to avoid the segmentation fault? I'm using gcc on a debian
machine.

Thanks for help.

Nov 14 '05 #1
3 2706
problem is solved, %n in printf caused the trouble.

Nov 14 '05 #2
problem is solved, %n in printf caused the trouble.

Nov 14 '05 #3
On Mon, 06 Dec 2004 06:39:13 -0800, crowl wrote:
I have written a program which logs to mysql database. Error routines
should handle the worst case if something goes wrong. In my tests I get
a segmentation fault if I stop the mysql database (stopping after the
mysql connection was successfully). It breaks at this line:
iErr=mysql_errno(&f->f_hmysql);


Discussion of MySQL specific issues is off topic for comp.lang.c, however
you may have a simple C problem. Unfortunately it is not possible to tell
given the information you have posted. Perhaps f or what it points to
haven't been initialised correctly.

Lawrence
Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: OneSolution | last post by:
I want to find out how I can ensure that if MySql has a burp and can't write to my DB, I will have a way of capturing the error and show my users something more pleasing than a system error...
3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
0
by: OneSolution | last post by:
I want to find out how I can ensure that if MySql has a burp and can't write to my DB, I will have a way of capturing the error and show my users something more pleasing than a system error...
0
by: Robert Mazur | last post by:
Solaris 9 - sparc 64bit MySQL 5.0 alpha (installed using binary from MySQL) --------------------------------- Has anyone expereinced this? The client will launch locally and process SQL...
1
by: Malcolm Dew-Jones | last post by:
Hello I need to detect duplicate errors when using mysql to insert a row in a php program. (I assume that the php version should not make a difference, but I don't know that for sure, which is...
13
by: wideangle | last post by:
Hello there! I know it's stupid, but when creating a table in a mysql (win32) database, it won't let me create this "mytable". Here goes my ER_PARSE_ERROR. mysql> CREATE TABLE `mytable` ( ->...
2
by: Ramza Brown | last post by:
This mysql_error doesnt give me an error below, but when I run it at the global scope it does give me errors. I went ahead and checked for mysql_error(), but normally I dont have to, why? ...
1
by: Joseph S. | last post by:
Hi all, (1) The "standard method" for handling errors when executing queries to a mysql database, which is shown in most tutorials and books is: mysql($query) or die("select/insert/update/delete...
21
by: bruno_guedesav | last post by:
I've made a function to fetch all results as an array of result- arrays. Getting the result arrays is easy, via mysql_fetch_array, and function itself is quite simple, as follows: function...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.