This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Mysql: adding to a database

Old posts that have not been replied to for several years.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

do not set the field to date time set it to decimal or int
XplaiN but think of me as stupid
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Post by SmokeyOne »

okay I got it setup working with adding, now I have to see if I can get delete working, and then the searching funtion.

now with the serach i can just use -limit 10 for it to display the first 10 results, but then would it be better to use a switch or, a else if statment to use for another string ? like !list 99 or something ?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

Limit is a mysql statement right then hmm u need to check the Mysql reference also if your making a search script also check LIKE
XplaiN but think of me as stupid
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Post by SmokeyOne »

okay I can list the db somewhat, though I would like to create a header and a footer, seems that might be the only way... also i tired to split it up in 3 ways like Ttle: Data: Date:, and I justed [join [lrange $qurey 1]] but it says its needs a end, i don't remember how to stop it at just that filed so i can display the date information on another line..
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

split up the date just use one string like unix time and use clock format unix time is all decimal chars and u can use it in php as well if you wana use webbased [censored] afterwards unixtime is almost reconized in any code so you can format anything from that way beter then spliting dates and [censored]

But this is totaly up to you
XplaiN but think of me as stupid
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Post by SmokeyOne »

okay well it works somewhat... now if I can get the header and the footer to display once, then show the list.... that's the problem I tried a older method, but it started to give me tcl errors.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

what header i mean header of what ? .. what do you mean

hmm normal
puts header

while ...
puts list ...
close ...

puts footer
XplaiN but think of me as stupid
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Post by SmokeyOne »

its been awhile since I was last on the net... my net time is starting to get smaller and smaller.. well anyways.. I beleive what I meant as a header and footer was.

New releases by Blah
1.
2.
3.
4.
checks us out on the web at http://www.blah.com

instead it was doing the top and bottom half over and over with each posting of the list.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

could u xplain what that is supposed to be ? and how did u make the country thing looks kinda cool was looking for something like it for my website tnx in advance
XplaiN but think of me as stupid
S
SmokeyOne
Halfop
Posts: 69
Joined: Tue Jan 14, 2003 6:04 am

Back At it again

Post by SmokeyOne »

after putting this stupid thing down for months, I'm trying again. Now from all my prvious posts I'm trying to retrive information and add information into a mysql database. using pub commands, my old code looks like this, someone let me know wtf I'm doing wrong here.

Code: Select all

#Adding Routine
proc add:pub {nick uhost handle channel arg} {
	global mysql net
	set arg [rls:filter $arg]
	set table $mysql(release_table)
	set sql(conn) [mysqlconnect -host $mysql(host) -user $mysql(user) -password $mysql(pass)]
	mysqluse $sql(conn) $mysql(data)
	mysqlexec $sql(conn) "INSERT INTO '$table' ( 'id' , 'release_data' , 'release_date' ) VALUES ( '', $arg' , NOW( ))"
	mysqlclose $sql(conn)
	pustserv "NOTICE $nick :Release has been added"
	putcmdlog "<<$nick>> !$handle! Added a new Release to the database."
}
#Deleting Routine
bind pub - !del del:pub
proc del:pub {nick uhost handle channel arg} {
	global mysql net
	set table $mysql(release_table)
	set id ""
	set sql(conn) [mysqlconnect -host $mysql(host) -user $mysql(user) -password $mysql(pass)]
	mysqluse $sql(conn) $mysq(data)
	if {[string is integer $arg]} {
		set id [lindex [lindex [mysqlsel $sql(conn) "SELECT * FROM `$table` ORDER BY id ASC LIMIT [expr $arg -1],1;" -list] 0] 0]
		} elseif {[lindex $arg 0] == "-id" && [string is integer [lindex $arg 1]]} {
			set id [lindex $arg 1]
		}
		if {$id != ""} { set result [mysqlexec $sql(conn) "DELETE FROM `$table` WHERE `id` = '$id'"] }
		mysqlclose $sql(conn)
		if {$result != 0} {
			putserv "PRIVMSG $channel :Release has been deleted"
			putcmdlog "<<$nick>> !$handle! Deleted a Release in $channel."
		} else {putserv "PRIVMSG $channel :No such Release in database"}
	}
now i'm also trying to add a search string to allow to search for more than 10 but i also only want displayed the first 10 releases. here is that code

Code: Select all

proc rls_show {nick uhost hand chan arg} {
	global mysql net
	set sql(conn) [mysqlconnect -host $mysql(host) -user $mysql(user) -password $mysql(pass)]
	mysqluse $sql(conn)
	mysqlsel $mysql(data) "SELECT id, release_data, release_date FROM $mysql(table)" -list
	putserv "PRIVMSG $nick :The Following is the 10 Newest Releases by \002blah\002"
	putserv "PRIVMSG $nick :Title:$release_data Date:$release_date"
	putserv "PRIVMSG $nick :TO search for more releases use !new #, or !new all"
I need to know what I'm doing wrong so I can start to fix this stupid problem. I'm open to all suggestions you have.. thanks


Also on the announcing part of the serach I get each line over and over like this
blah blah bhla
1.
blah blah blah
blahblahblah
2.
blah blah blha

instead of
blah blah blah
1.
2.
3.
blha blha blha

Thanks for any help


Smokey[/code]
Locked