Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Quit
Wanderer


Joined: 19 Jul 2008
Posts: 59

PostPosted: Sun Mar 04, 2012 10:14 pm   

Sql Error
 
Hi

Why do I get this error: SQL Error: MySQL server has gone away.

I can connect to my server with other programs, so nothing wrong with the server.

If I close and reopen Cmud its all ok and every thing works.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Mar 04, 2012 11:33 pm   
 
Did you make any changes to the DB structure while CMud was connected to it? Even though you CAN do this, you're not supposed to and typically any connections in effect after you make those changes will break the next time they are used to access the DB.
_________________
EDIT: I didn't like my old signature
Reply with quote
Quit
Wanderer


Joined: 19 Jul 2008
Posts: 59

PostPosted: Mon Mar 05, 2012 7:10 pm   
 
I think its only happen when I wake my computer from sleep.

But I found something else.

When I run this, it put the data in the server, but if I keep running this with the same data, it keeps putting the data in
so I got more rows with the same data, think I need to do -update- the server or something ?

Code:
db = %sqldb("database", "aardwolf", "mysql", "qnap" ,"xxx")
#CALL @db.Open
row = %sql(database, "SELECT * FROM mobs WHERE mobname= '@questmobname' AND zonename= '@questmobzone'")
#SHOW @row.RecordCount
#IF (@row.RecordCount = 0) {
update=%concat("INSERT INTO mobs (mylevel, mobname, zonename, zonenum, roomname, roomnum) VALUES ('"%gmcp.char.status.level"', '"%gmcp.comm.quest.targ"', '"%remove("The ",%gmcp.comm.quest.area)"', '"%zonenum()"', '"%gmcp.comm.quest.room"', '"%roomnum()"');")
#CALL @db.Execute(@update) } {
  #WHILE (!@row.Eof()) {
    #SHOW Room: @row.Item("roomname")
    #CALL @row.Next}
}
#CALL @db.Close
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Mar 06, 2012 12:55 am   
 
INSERT is for making new records, UPDATE is for changing existing ones. Dunno if MySQL has a reference website specific to it, but for the generic SQL you can check out w3schools.com for awesome tutorials.
_________________
EDIT: I didn't like my old signature
Reply with quote
Quit
Wanderer


Joined: 19 Jul 2008
Posts: 59

PostPosted: Tue Mar 06, 2012 8:45 am   
 
I know the UPDATE command.

But my script open a connection, check to see if the name and zone exits,
if NOT, then INSERT new data and the close the connection.

But its like, it keeps the connection open so it does not see the change to the server,
and I can keep INSERT the same data

I do believe that a new connection should work like a refresh of the server.

I also use a program called HeidiSQL and here I can see if I press the refresh button
it reconnect to the server.

So I do think that #CALL @db.Close does not work.
Reply with quote
hogarius
Adept


Joined: 29 Jan 2003
Posts: 221
Location: islands.genesismuds.org

PostPosted: Tue Mar 06, 2012 12:33 pm   
 
Does the #SHOW @row.RecordCount line ever show a value that is not 0?

Try entering a line #CALL db.Refresh immediately after the #CALL db.Open line.
Reply with quote
Quit
Wanderer


Joined: 19 Jul 2008
Posts: 59

PostPosted: Tue Mar 06, 2012 2:39 pm   
 
no the @row.RecordCount stay on 0, but it do change if it find old data.

#CALL @db.Refresh give a error: No method/property: Refresh
Reply with quote
Quit
Wanderer


Joined: 19 Jul 2008
Posts: 59

PostPosted: Tue Mar 13, 2012 9:13 pm   
 
Finally I got it to work Very Happy

here is the code if it can help anyone:

Code:
lkname = %subregex( {%1}, "'", "\'")
lklevel = {%2}
lkzone = %subregex( {%4}, "'", "\'")
lkroom = %subregex( %gmcp.room.info.name, "'", "\'")
lkroomnum = %gmcp.room.info.num

db = %sqldb( "database", "aardwolf", "mysql", "qnap" , "XXXX")
#CALL @db.Open
row = %sql( database, "SELECT * FROM lastkill WHERE name='"@lkname"' AND zone='"@lkzone"'")
#IF (@row.RecordCount = 0) {
  #CALL @row.Edit
  row.Item("name") = @lkname
  row.Item("level") = @lklevel
  row.Item("zone") = @lkzone
  row.Item("room") = @lkroom
  row.Item("vnum") = @lkroomnum
  #CALL @row.post
  #CALL @db.Close
  }
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net