i have a problem i have an object which comes from an array with the keys not being 0 1 2 and so on for example

does javascript have the ** operator?

See Math.pow().

for(i=1;i=36;i++){Math.sin(Math.PI/18*i)}

undefined

b=[];for(i=1;i=36;i++){b.push(Math.sin(Math.PI/18*i))};b

{ }

b=[];for(i=1;i=36;i++){b.push(Math.sin(Math.PI/18*i))};b

{ 0: 0.17364817766693033, 1: 0.3420201433256687, 2: 0.49999999999999994, 3: 0.6427876096865393, 4: 0.766044443118978, 5: 0.8660254037844386, 6: 0.9396926207859083, 7: 0.984807753012208, 8: 1, 9: 0.984807753012208, 10: 0.9396926207859084, 11: 0.866025

Whee

can I do an onchange for a textbox ?

Yes, you can on all form elements.

so what constitutes an onchange for a textbox
typing a character?
as in entering/removing characters

yup

is this possible http://www.pastebin.ca/658144

The paste 658144 has been copied to http://erxz.com/pb/4050

hello all
I am trying to make a simple javascript host menu using mouseover for images
i was trying to find the code to do it online with no luck

just change the src and you are set DARKGirl

it's ok to declare variables without var, right?

onMouseOver="this.src='newimage.gif';"

is this possible http://www.pastebin.ca/658144

The paste 658144 has been copied to: http://erxz.com/pb/4050

How do I get the content of a atag/a?

Multiply ref.innerHTML
Renacor var x = { y: 5, z: 'bleh' }

Isn't there other ways, but innerHTML?
And I want it to be lowercase.

Such as?
If it's a single text node, ref.firstChild.nodeValue does the job.

can I have another object in x
as in x.y.z = bleh
x.a.z = meh

Okay.

Renacor var x = { y: { } }

cool thanks

TheCastor, how do I make the nodes value lowercase, then?

nodeValue is a string
string.toLowerCase()

Oops, I used toLower()

if i have a document.i_want_a_variable_here.foo can i say document.+my_variable_name+.foo ?

document[myVariable].foo
window['document'][myvariable]['foo'] for the understanding

Ahh!
understanding takenth

http://paste.cplusplus.se/paste.php?id=6417 what's wrong with the returnWords() function? The loop isn't run at all

tag's class to a specific class, if their href is f.ex http://foo.bar?

Gambaroni are you sure you don't get a js exception in your console? something like… http_Request has no properties

Nope.. in FF it works

result.getElementsByTagName("word").length is greater than 0 ?

Multiply, var links=document.links; for(var i=0; i links.length;i++){var cur = links[i]; if(cur.href == 'http://foo.bar'){ cur.className='spesificClassName' } }

by the way instead of calling it in the for and every where, you should use a variable, var collection = result.getElementsByTagName("word");

StaZ|Work in IE7 no, in FF yes

element in your page ?

dabear, thank you

StaZ|Work yes
4 even

i've never heard of this tag
it exists or you invented it ?

my invent

FF might not like that

It an own created XML document

and getElementsByClassName

xml !?
hm… wait a mint
oh lol
fjer

:P

fjer?

well, sorry that's out of my reach
dabear yeah that my head on the keyboard

Then get up and in reach.

7y67yu6
that's my head on the keyboard ^^

that's 2 htis
hits

eval(return 'prods.bc.q' + qty);

return 'prods.bc.q'+qty

0

huh
how do you write it
just like that?

qty=555; return 'prods.bc.q'+qty

''ERROR: Can't modify constant item in scalar assignment at (eval 212) line 1, at EOF

i wanna put it in a function parameter

var qty=555; return 'prods.bc.q'+qty

''ERROR: 13401: Can't locate object method "var" via package "qty" (perhaps you forgot to load "qty"?) at (eval 212) line 1.

what?

return 'prod.bc.q'+qty) ?

Renacor, try function(a, eval('prod.bc.q'+qty))

yeah doing that now, thanks

nm
555

"ShaunO" at 71.6.194.243 pasted "Reliable way to preload images?" (13 lines) at http://erxz.com/pb/4051

^^ Anyone wanna take a look for me?
(please)

ShaunO`: what's up?

Just wondering if that's a decent way to go about preloading images
http://erxz.com/pb/4051
Not 100% sure on it
initWeb() is called in the body of the page onload

does it work?

im not sure to be honest.. im going to test now i gues
just by using large files

hi, anyone know how i could highlight not just the row of a table im hovering over but the row below it too?

empika, you could use currentRow.nextSibling()

ShaunO`: good luck

thanks, ill have a look into that

is there an isset() like function for javascript

Renacor, just check if whateverValue !0 undefined
whateverValue != undefined

Thanks stickto, just fyi it worked perfectly in all browsers, firefox, ie6, safari, opera

ShaunO`, excellent, I will use the method as needed, thanks

Images definitely being preloaded with the JS since there aren't any other references in the web page until it gets put by javascript ajax

ShaunO`: what if remove "preloadImage = null;"
and remove "var preLoadImage = new Image();"
just change the src attr again & again

stickto, may work.. not sure cbf testing now its nearly 2am and im tired :P

ShaunO`: oh, you are not in US?

new zealand

ShaunO`: oh, you always work so late?

sometimes..
i been working on a new project for myself
learning a lot as i go..
but i also work on learning this sort of stuff at my day job at computer sales :P

diligent

this is the project at the moment.. only this one page so far and no backend yet.. but at least 99% of javascript is done and the layout i'm happy with.. took me about a day or two of frustration and whatnot but it's 100% compatible all browsers, valid xhtml and css etc.. the url is - http://www.filespin.net/fs/
it's a registration page for a sort of free hosting type thing
when you enter a field that needs to be unique it will validate as you go down the form thru ajax and php
but that part isn't done yet
all the javascript/client-side validation is done though
it's going to be re-verified with php on post as well anyway

b

but i can reuse a lot of the code and regexps..

=[

anyway, enough of my blabbering, night..

ShaunO`: good night, the cross-platform js is hard to write

it's easy if you stick to the basics and standard(s)

i have been annoyed by it

easier now that ie7 is a bit better
and safari for windows too… don't need a mac to test with =]

Hope so
deal with IE & Firefox is exhausive

rule 1) code for firefox, fix/hack for ie
people that refuse to fix for ie are being a little bit silly imo because it's still a lot of users that use IE.. although it depends on your target audience.. a website targetted at advanced linux users for example probably doesn't care
likewise for people that refuse to fix for firefox.. silly.
too time consuming my ass.

yes

(fixing larger websites that have been around for a long time)

many sites perform incorrectly in firefox
what's rule 2

stick to the standards.. that way your website will last a long time
if it's full of hacks, the next browser update could screw it all up

the problem is that most of us study js programming under IE
sometimes we can't tell if a line of code comfort with standard

like this - new ActiveXObject("Microsoft.XMLHTTP");

in fact, In IE6, you must write the code to create the xmlhttprequest object

hi. to remove an arbitrary item in the array, I could use slice, yeah? arrayName.slice(3,4);?
hello. can someone refresh my memory how to remove an arbitrary item in an array knowing its index? is it slice or splice?

is there a way to do something like this with js? function foo(){ alert(this.count_input_params); } then call foo('1','mine','bar'); and have it return 3?

splice should work
splice(index,1)

heh, tried that… but somehow it's removing random items which is weird…

what the hell are you asking?

heh

oh, hold on, i hear you
yeah, you can do that
alert(arguments.length)

ah…cool
thanks

splice(index,1) should work. if it's removing random items, something else must be wrong.
http://www.javascriptkit.com/jsref/arrays.shtml

(document.getElementById("foo").select()).focus();

hi all

hi, rawtaz

i have a problem.. i have an object which comes from an array with the keys not being 0, 1, 2 and so on. for example i have object.10013, object.10002, object.10007 . now id like to do two things with this object/array.. 1) id like to loop each of its elements, and 2) id like to just get the
first of its elements. how would i do this?
usually i have an array with 0-X as the keys, then i just do a for loop that checks for .length, but thats not possible here

When I'm referencing using document.getElementById('whatever').value using a textarea, is the attribute for the content "value" or something else

It's value. Try look it up in MDC before asking

Thanks and sorry.

nothing to be sorry bout, it was a suggstion, you'll get your answer faster from the MDC

element's options does not count as an onchange event?

with the keyboard

Renacor, ’cause a change of the value doesn't happen untill the value is clicked (or you use the enter key)

thats kind of silly
the value gets displayed differently but there is no onchange
aha, whats this onkeyup

question … is it possible to put a variable within a pattern for use with .match()?

MysticOne, .match(aVar)

I'm trying to combine it with a regular expression, though

MysticOne, if you want the var to be included in the regex it selg, you must use new Regex() instead of //.match()

create a regular expression using the syntax var my = new RegExp("\\w" + variable + "\\d");

new Regex(var here pluss regex).match()

ahhh, okay
so RegEx will take the string and convert it to a regular expression

Not "Regex" but "RegExp"…

err, yeah … sorry
left the p off

Plus the uppercase E.

hello all
can someone direct me to a page that allows me to create a menu that is based on images?

anyone here used sproutcore?

http://www.dynamicdrive.com/dynamicindex1/chrome/index.htm

no no not a dropdown menu
something very simple

I cant see my POST and GET-calls in my firebug, does anyone know what might have happened?

you roll the mouse over it and it highlights, you click and it goes the the next page

awesome, got it to work thanks!

np

anyone?

How can I change the default-value in a dropdown dynamically using javascript?

well let me tell you what images I have and maybe it would make more sense
I have a whole menu for each page with the title pre-highlighted

maybe this http://www.cssplay.co.uk/menus/menu5teen.html

and I have small images that change for mouseover
that CSS play menubar is exactly what I want
you know the one with 'Demos', Menus, Layouts, Boxes, etc

You mean the top one?

yup

kanzie, theSelectBox.defaultValue

http://www.cssplay.co.uk/menus/neon_menu.html

yes!
thank you!!

NP

god IE is so silly, it just doesn't like setting onchanges with setAttribute?

where is the code?
is it in source?

Read it. He says its building it based on the previous tutorial. Come on girl, put in some effort…
You can also do view source.

sorry just too excited i suppose
ive been looking for this for a while

Hey
is there any way to get the path of a file that cointains the code with JS?

I'm doing a els=document.getElements…() and I thought it returns an array, but when I try to do els.concat(els2), my browse complains that els.contact() is not a function
as thought els is not a bona fide array

Actually 'els.contact()' is not a function, its 'els.concat()'

chrismon, it returns an element node list, not an array

er year concat
bjorn, ahhh

that wont work
that uses only 2 images
I have 16
i need to use javascript for this

I am sure you can make some adjustments…

i cant
because of the unique shape of the menu

Thats exactly the point I am trying to make. Since you have a custom requirement, you would have to read similar examples and come up with something original.

??????????
is there any way to get the path of a file that cointains the code with JS?

does anyone know how to use the prototype chain to determine a instance class?

does anyone follow any personal guidelines on when to use innerHTML vs. create/clone nodes?

Hi, I'm trying to write a perl script to automate browsing this webpage. The webpage makes a reference to a javascript function (which i did not write!) and I can't find the source for that function… its like it links to nowhere
select name="sendTo" onchange="javascript:listAction(document.listForm, document.sendToForm.sendTo.value)"
is javascript:listAction part of java script, like Math.log() or something?

hi. i am using this simpla javascript function to toggle the visibility of a div. it works fine in firefox but in IE, the div is displayed out to the right of the page rather than below. is there anything i can do from js to fix this? http://pastebin.com/da63fb7e

No its not a standard javascript function. Its a user defined one.

Isn't there like a firefox extension or something that will say "this javascript function is found on line X of this file?"

Bah, I hate people.

http://pastebin.ca/658448 ?

you could use firebug, view scripts, and then search

I searched the source of the webpage and all the included js scripts, and none of them had that function

The paste 658448 has been copied to http://erxz.com/pb/4052

But its not a standard Javascript function thats for sure.

Two implementations of vi in javascript, both with 'closed' licences http://www.masswerk.at/jsuix/jsuix_support/jsuix_vi.js http://gpl.internetconnection.net/vi/vi.js

I'd tell you to join the club, but I had to disband it when I realized I hated everyone in it too.

Ha

why would you put something in java script under a closed license? you have to release the code anyway… its javascript!

But it's so easy to get security through obscurity by compressing and encoding it.

Well yeah. But I'm not just going to suddenly go and disrespect their licence.
Well, neither of them are.

It doesn't matter whether you can see the source code or not. If its under license, you just can't use it.

Yes you can. It just depends on what the licence says.

Aankhen“: doesn't the webrowser still have to decrypt it?

Of course, someone could put it under a closed-source licence and thereby prevent you from using it.
I did say "security through obscurity", did I not? :-)
It's a nice, warm, completely unfounded sense of security.

Aankhen“: I meant closed license.

Aankhen“: that only stops stupid people

OK.

level1__ - then it stops the majority, right?

What part of what I said was unclear? :-S
karma MikeD_ perceptive

level1__, Wait, are you calling me stupid for obeying the license?

Argh.

not the licence, the security through obscurity

Oh, right, not keeping up.

http://pastebin.ca/658448 ?

The paste 658448 has been copied to: http://erxz.com/pb/4052

you need commas, but yes

cool thanks

I've used firebug to search the entire page. listAction is used dozens of times, but never defined

sounds like it's not defined then

ack! where is it!

do you own this code, or are you trying to understand someone else's?

it probably does something stupid like set a number from 0 to 1… but I can't figure out what it is!
someone else's
I'm trying to automate a web page… I'm almost done, this is the last step

Anyone here a php web hosting programmer? What's the equivalent of str_replace() in Javascript?

hi all

wait, listAction shows up in the DOM tree in firebug
but it just says "prototype"… thats not helpful

Don't know about PHP but there is a function replace in javascript.

string replacement JLearn?

YES!
I found my OOOLLLD code that I made ages ago
but
I am not sure I did it properly
care to look at it and tell me if its 'legal' code?

I'll try though I am not in menu stuff and all that.

meh, its only a bunch of javascript and divs

or better - something that converts whitespace to entities that can be passed through URLs.

Look at Strings' replace function.

we dont have to chat in the query, because you are talking to other people and it would be a pain
hmm
I shall have to edit up that code a bit I am sure
because my new site doesnt use frames
apparently frames are EVIL

Correct.

but other than that…the layout; the way I am doing it, is it ok?

The way you call imgOn and imgOff functions is wrong. You pass a string representign the name of the img and inside the function, you treat that name as if it were the image element.
Oh no wait, you are using document[imgName], then its OK. Ignore the previous message .

guys, can i store a function name on an attribute, then execute it?

ok hehe

the code looks OK. Do let me know if you face problem executing it…

ok, thank you. I was hoping all the div tags werent a bit…much

If it works for you, then its OK.

and the manner I use the z-index
although, I wont have so many layers this time
only 2

Like I said before, I am not much into CSS and designing though your code looks valid.

can i execute a function based on a string?

Your code executes fine on IE here…
yes

how?
i need to create a new event on my div
callAfter="someFunc()"
after, inside my script, i need to div.getAttribute('callAfter') ?
how do i execute it?

do window[yourFunctionName](your_function_parameters)

so will be window[div.getAttribute('callAfter')](your_function_parameters) ?

hrm… I'm running a getElementsByName() and FF2 get the list correctly, but IE6 and IE7 do not find it

If that function returns the string containing the function name, yes.

on google I find issues with getElementsByTagName()…
er one sec…

JLearn, thats it, cheers man

Welcome

Hi all
I'm pretty much a Javascript n00b

with a b00b?

Sheesh…

In the Facebook Platform - it says that onconfirm is an event handler that fires when etc.

I love n00bs with b00bs

How do I change this onconfirm thing?
this.onconform?

What are you trying to do?

anyone knows if it is possible to get the path of the file that is executing the js code? for example /leayout/js/file.js

hola Aquaman

hey :P

In your code you had document[imgName], replace it with document.images[imgName]

ok, thank you

anyoneeee?

Don't think you can do tha Aquaman…

[JLear1] and can I get values from the url?
like the $_GET in PHP

You mean the query string parameters?
http://www.google.com?do=something

nope something like, file.js?something=value

Now why would someone do that!!

hahahaahha
because I need to pass a dinamic value for a path
I need to import a JS inside that JS, and the path to the second file has some dinamic value that depends on the user

Ah…that would require some thinking…

script language="javascript" src="{PATH: STYLE_BASE}resources/js/goear.js" type="text/javascript"/script

This is your base JS, right?

thing would be replaced by /styles/glow, but could also be replaced by /styles/blue/

Oh..why not just use PHP to do selective script loading?

I have a textbox and a button. The textbox has a blur event. The button has a click event. After typing in the text box, if i click the button. The blur event fires, however the click event does not. the blur event does not return naything, and does not have a stop bubble.

yeah that would be the base JS and then I would like to import the rest of the js files needed for that layout

Depending on the user input just create a if else mesh and do a selective script loading instead of the stuff you are trying to do.

in the html code, I want to import all the JS files inside a unique JS file and import that JS file in the html code

element which was included and not every script tag since your PHP would have made a choice by then.

could someone kindly explain "this" to me… this.element

mmmm I will try something like that

ultravi01 okay so when you're in an object, this, is the object

[ultravi01] http://www.quirksmode.org/js/this.html
read that

ah okay.. thanks guys

In normal scenarios, this is the window object.

you got examples and stuff

http://uncyclopedia.org/wiki/This

lol

!
oops

is it possible to have some kind of loop through elements in an object?

what's the object literal notation for a null value? var foo = { prop : null };

for(var property in object) { alert(property + ' : ' + object[property]); }

perfect
thanks

Welcome

how can I count the number of sub objects in an object?

Renacor, every property will be an object..

Im trying to count the number of objects in my user created object

for(var property in object)

will this also count the built in javascript hosting properties, or do they not exist in an user created object

why does new Option use 'text' node?

awesome I think that worked, thanks
btw anybody know the maximum length for a get string?
i.e. index.php?blah=blah&foo=foo

if you have to ask, you're going to go over it
it might be browser dependant but i think it's something like 1 or 2k
use post

Its counted in characters and not K's…

… or some other cereal brand

No, only in characters.

what does that mean?
oh

i see
so is there a foreach like statement in javascript to loop through an object's sub objects?
or is it just the for(i in objectname)
nm got it

there is a .forEach() but that's not supported by all browsers

So I hacked up this popup window thing so that the onclick of my href creates a popup menu then returns false; so the actual href redirect never happens. This is what I want to happen but not the popup window that pops up follows my mouse around

Hello
If users click on a hyperlink on my website, what code do I write for the link to open in a new window?

anyone know if it's possible to have a google map update based on onkeypressup ??
i want a textarea to automatically update a goole map while the user is typing

it uses dhtmlwindow.open() to create the popup . Is there an argument I can pass to it to make it not follow my mouse?

tag should be _blank

Okay.
Now for something more complicated. How do I make it open in a new Tab (say, Firefox/IE7/Opera)?

when I double click on a scriptaculous BlindDown link, it works fine, but next time it gets BlindDown'd it only opens up part way — any ideas why this may be?

Anyone every used overlib() ?
ever*

That is not your domain. You don't decide whether the thing opens up in a tab or a new window.

But, window.open is by default open in new tab in newer browsers, yes?

Firefox and other browsers allow the user to decide which way they want it through preferences.

is there an overhead with new myobject() ?

yeah, probably the sky will fall on your head
(that was a sarcastic comment, please explain a ltitle further)

just wonder if I can aplly factory pattern

What are you talking about. The overhead to object instantiation?

"I want to implement a factory pattern, does instaciating new objects with newMyobject() will create an overhead in this situation : link to code on paste site here"
have you tried googling "Javascript factory pattern
?

If you want to use an object, you have to anyways instantiate it. Be it via factory pattern or normal manner…

doing it right now

Guys.
Why does my browser not show a new browserwindow with all the buttons on it when I use window.open? It just pops up a new window with no buttons and my page in it.

a href='your_url' target='_blank'SOme link/a

:P hm
And someone with a popup blocker would still work with that?

Nope

So the popup blocker would block it?

Yes

Damn ittt.
Pff.

Thats why sites don't use popups anymore…

I'll just put a line in my website "open this link in a new page please"
What if,
I want to refer to a completely different website
Like

found it in google, there's such thing as factory pattern in javascript

http://users.telenet.be/treval/

http://www.webreference.com/programming/javascript/ncz/column5/

What if the user is on my current, old website.

what link Treval

And I want to link him/her to my new website
The one that says 'home'
and the one 'treval time'
I don't want them to open up my new website within my old website

Urgh, look people can chose.

bah

Treval, it opens up a new page for me
a new window I should say

Does that new window have buttons?

The Treval Time window does
( FireFox here )

Wthell..
I'm using forefox too but
I mean "back", forward
buttons
Do you have a menu bar?
In that window

although I do remember an argument to window.open() that tells whether to include the menu set or not
yes

Opens in a new tab for me.

But I don't!

grimboy, same

Why not me..
sigh

Treval, Learn to configure your browser.

What argument do I need to set to include menu?

Treval, I am not sure. Google for window.open arguments maybe and look at the list. There is one there that is exactly that, tells it whether to open one without buttons or with buttons.

is there anyway to print or write a structured array
like "print_r" in php

Firebug
`firebug

Is there any way to make it so when a hover over a class item occurs, the hover effect stays (doesnt revert when rollout). Like on this site: http://meyerweb.com/eric/css/edge/popups/demo2.html but when u hover i want the item to
stay and replace when a new is hovered.

well yeah… onmouseenter="setpicutre(something);"
and don't put code onmouseexit

an array can hold any objects, right? array[0] = var new Object();?

atula, yes

thanks

Guys
Do the 'home' and 'treval time' links open in a new page/tab? http://users.telenet.be/treval/

you mean onmouseover?

Yes, yes he does.

you can try with that too
mouseenter don't exist?

onmouseover is in the specification

Okay if anyone posts any more crap badmouthing my website I will personally attack them. Stop posting shit in my shoutbox!

hm
?

Oh shush.

home doesn'T, and i don't find treval time

http://javascript.internet.com/miscellaneous/set-image.html
This will work If I can find a way to also post text.

is there any function to get random string of characters ?

yeah use a random to get a number from 1 to 26 and add it to 0×40 (or 0×60 for small letters) and do that n times
0×41 is "A", 0×61 is "a"

thanks

np
so might need to google for javascript random function, javascript ascii code function and more if you miss other topics

anyone know why when I get an element's contents with document.getElementById(id).innerHTML, it adds a ton of whitespace before and after?

http://fukung.net/images/4733/random_number.png
a href="http://fukung.net/images/4733/random_number.png"http://fukung.net/images/4733/random_number.png/a
xike inner html is evil do you know about DOM ?

StaZ|Work, but the synthax is invalid!!

I know what it stands for :P

bjorninge it's C syntax.
xike well you might want to get the child of your element and do something with that isntead of the inenrHTML OR… if you want to be evil, you can use trim functions to cut out the white spaces

I'm fine with not being evil
if I can get the contents of something, and replace the contents, then that would be great
w3schools.com tutorial uses innerhtml. have any advice for a better example?

w3schools is not reputed for having the best code
xike are you aware that i don't know what you try to do ?

are they associated with w3c?

what is eval() ?

i am looking for a ajax/js script that counts clicks, like clickclickclick.com (without refrashing page and 'impossible' to fake clicks).. anyone?

xike no they aren't and that's the bad association most people will do
edini send them an email and buy it from them

ah..

level9wizard a bad function that evaluates the js code in it, if you use it, you probably have a bad code that could be structured better
"javascript click counter"
and for pr0n site it's "javascript click cunter"

i did, but.. i found only visit counters and stuff
not what i am looking for..

shouldnt there have been something that went on in your brain in between when you thought of that joke and wehn you said it?
like some kind of filter that checks for things like "humor" and "appropriateness"?

hrm. know of any good dom examples for getting/setting contents of items?

heh, it's pretty rare i make english jokes based on the language, gimme a break :P
i'm proud i could make one

ok i'll give you a pass this time

google "javascript howto what you wanna do" and check the pages you get, and also check google groups :P
vinse thanks ^^

ha, yeah…that's what I'm trying
horrible examples so far
I'll keep wandering…just thought you might know of a good resource
thanks

might also stick the word "DOM" in there
well i still don't know exactly what you wanna do
and my Mind reader is broken

lol, I've said it like 10 times
don't need a mind reader when I say stuff like " hrm. know of any good dom examples for getting/setting contents of items?"

that's not clear enough for me
biut you can document.cteateTextNode("hello!"); i think… and then .appedChild on the container
as for the reverse you can check .children[0] i think, but still not sure :P

.childNodes[0]

haven't worked with that for a long time
right sorry JLearn

lala

hi
what is recommended, adding html using innerHTML = "button.." or new Button/appendchild?

the latter

can you tell me why?

lots of reasons, one of the better ones in this case is that form elements often dont work hen added via innerHTML

okay thanx

Let's say I have a div id="text" , how can I use js to change in text into that from a function?

still looking.. :/

anyone know if it's possible to have a google map update based on onkeypressup ??

teh netsplit?

guys, whats the best way to dynamically change the element's onClick attribute?
i'm using element.setAttribute("onClick","func()"); but isn't working on IE

a am looking for script that counts clicks without refrashing page, like clickclickclick.com.. and, yes, i did try googling for "javascript click counter" and 100 other strings..

just element.onclick = function(){/* new contents*/}

but i need to point to another function
how do i reference it?

how hard can it be?

element.onclick = function(){ myFunc(args) } ??
element.onclick = myFunc() isnt working

yup
element.onclick = function(){ myFunc(args) } or element.onclick = myFunc // — if you want to give no args

ok
cheers!!
how will that behave? element.onclick = function(){ myFunc( document.getElementById( localVar ) ) }
when will doc.getElementbyId run?

if ( alphanumeric(document.editprofile.gender.value) ){
is that ok?
having a function that returns true or false in an if statement i mean

Uh, yeah

does anyone know of any tool (perhaps a firefox extension) that will show how..in what order… a javascript is executed..

firebug

I don't see where firebug does that

js ref
that's not handy
`js ref
anyway
js_ ref
nope

ultravi01, scripts tab.
Set a breakpoint
Then step through
Firebug has masses of hidden features. You really ought to read the manual to get the most out of it.
For example the other day I found out you can set conditional breakpoints.
So yeah/

thanks man!

is there any way to pass onreadystatechange a methodname AND a variable to pass to that method?

does this make sense? :
myobj = { foo: function() { return this.bar; }, bar: 0 }; myobj.bar = 4; myobj.foo()

4

(as in, you understand what it's doing rather than how it's relevant to your question at the moment)

not so much

ok then, try this
myobj = {} /* an empty object */; myobj.foo = function() { return this.bar; }; myobj.bar = 4; myobj.foo()

4

(buubot displays the value of the last statement in a jseval line if you couldn't tell)

you defined a new object, added a method to it that returns bar, then defined bar inside that object, then called that object.method to return it?

yes

ok…

now, myobj is your XmlHttpRequest object, foo is your onreadystatechange and bar is any information you want to be available when foo is called
methods on an object can access any information stored on that object using the this keyword
you don't want to pass arguments in through the callback (mainly because it's not possible), you want to store the information in the XHR object for the callback to pull out when it needs it

ok, well why create a new method/variable for the request object rather than set a method/variable for the current javascript?

"current javascript"?

let's say I have my poststuff() and onreadystateDoSomething() methods in a javascript file

2 reasons, if I understand you. 1) because information relevant to the request object makes sense to be stored in the request object, and 2) because onreadystatechange will probably be called when the "current javascript" scope has finished

ah
so do I somehow dynamically add that method/variable to the xhr object, or do I extend that object ahead of time and add that functionality to it?

see my second jseval
see where I set .bar and how I used it

selector.childNodes[i] — can you help?

that depends on what selector and i are

it contains more span

for (var i = 0; i 9; i++)

so I could simply use my existing xmlhttp object and say: xmlhttp.foo = function() { return this.bar; }; myobj.bar = 4; and it will work?

yep, should do

var selector = document.getElementById("selector")

what does alert(selector) give you after that?

anyone know if it's possible to have a google map update based on onkeypressup ??

I must have done something wrong, it says "xmlhttp.getId is not a function" once I call it in the triggered method

Object HTMLSpanElement

ok, now's a good time to explain what you expect and what's actually happening
pastebin some of your code
of course it is, javascript isn't fussy about what event triggers it

http://pastebin.com/d37338bf4

(in the page HTML), and I want to set their style.color

any ideas what i should look into. I'm new to both javascript and google maps.

var selector = document.getElementById("selector")
oops. Firefox reports selector.childNodes[i.style] has no properties

I can't see anything immediately wrong with that, I haven't ever tried this but there isn't any reason it shouldn't work
maybe try moving your .getId = and .id = before the .send?

typo selector.childNodes[i].style
ideas?

hopefully there's a live example page I can look at here

I can do that.

that worked, thanks a ton
I wish they didn't have the word "java" in the name…it makes me forget this is a scripting language

tab completion is your friend
my first name only has one 'a'

tab completion?

i used alert, it shows object Text

in your IRC window

again

how'd you know he was typing it Garath?

haha, nice. thanks for that tidbit too

that worked, thanks a ton

I had a good run of not spelling it wrong
so close

i was joking, that's why i repeated the spelling … too subtle for irc though, sorry
cant convey sarcastic tone :/
how'd you know he was typing it gaRATH?
would that have gotten it across? still not funny though so nm

should i put ';' after this: e.onclick = function() { someStuff() } ???

semicolons are optional but recommended in javascript

e.onclick = function() { someStuff() } or e.onclick = function() { someStuff() };
for every line? :]

you need them if you're putting two statements on the same line

so i'll use them

otherwise you can miss them out and the interpreter will still work
but do use them

ok! cheers!
damn it, why coding for IE is so sux!?
FF goes ok, but IE show "Error on page", with poor descriptions… :/
is there any "firebug" for IE??
something that shows where the error is

how can i check if a dynamic function name has been declared? im trying eval('if ( ' + dynamicfunctionname + ' ) { alert("bla"); }'); to no avail

when I try to get the contents of a textarea, I get the previous contents, without any of the changes that may have been made. how can I get current text?

hi guys. i have a Tooltip class and i use it to create various tooltips. right now i have 8 toolips that can be opened concurrently. when i delete the tooltip, i want to have a destroy() method in the Tooltip class that will delete all references to that tooltip.
is it possible to have a "delete this;" command in the destroy() method of the Tooltip class? (to delete the object itself)
currently when i do this IE gives me a "cannot delete this" error.
also, if my syntax is wrong and it is really possible — do i really need to do that? i'm trying to do a nice cleanup when tooltips are deleted

guys, is it safe to use innerHTML on ajax responses (not little text, something important like a new form)? or is it better to respond using json and update/create elements via DOM?
in FF is going everything perfect, but i don't know on other browsers

always do things via DOM to be safe
use mootools for ease of use and cleanliness

mootools?
I don't know it, going to find out
cheers m8
i've asked bcoz i'm using someone's AjaxTabs script , looking inside, it gets the content and insert into the "tabcontent" div via innerHTML
i'll have to tweak it

innerHTML will work anyway, but using DOM is always preferred

yes.. specially bcoz i'll need to find this new elements via DOM latter

http://pastebin.com/mf5a8df0 whenever i call search function, in IE it works just fine, but when its used in FF it bugs out help is appreciated.

good morning

good mornin

the cursor doesn't turn into the finger and it doesn't get highlighted.

any suggestions?
ok, i just figured it out… a href="javascript:;"

can someone look at http://mcgw.dav7.net:8181/template/bookmarks.js and see if they can figure out why i get the error "CreateBookmarkLink is not defined'?

I cant seem to figure out why my script isnt working for firefox, can someone please take a look http://pastebin.com/mf5a8df0.
does getElementByName work in FF?

elements?

what else should i use?

that function won't work in any browser
any visible element can have an onclick

yes, but it doesn't do the pretty highlighting thing automatically.
i'd have to add some sort of onMouseOver stuff.

if you want to change presentation, use CSS
cursor:pointer will deal with the mouse cursor

so the only thing to get values from inputs would be getElementByID? there is none that goes by name?

as in span.action { cursor: pointer; color: red; }
getElementsByName should work fine

doesnt that return an array?

the clue being that more than one element in a document can have the same name, but only one element can have a particular ID
yes, see the previous response
you might know that only one element has that name but the HTML spec can't guarantee it so you get an array

i see, but then how do you just get the value of that one
document.getElementsByName('Location').value[0] ?

just use the first element of that array
not quite
document.getElementsByName('Location') is the array, not document.getElementsByName('Location').value

oh so
[0].value

yep

i get it now, i really appreciate it, think ill just add the id to the inputs lol

lol

is it very unsafe to use eval() on an string extracted from a element's attribute? (this element is part of my static html, not dynamically generated)

brb

ah?

hey i've got a pretty popup box, and i want to replicate the javascript confirm method but using the pretty box. Any idea on how it prevents the current action from occuring?

if a handler returns false, no other processing of the event should occur

if bla returns false nothing should happen?

right
um, maybe "return bla();"

Why is it that in Internet explorer when i have it load a dropdown menu the default selected one is always one above the one i tell it to be selected so for instance [3] is the one i want selected by default it selects [2] but in FF it does it just fine. Then if i dont load the function on
load and just do it on change it does it right.

hi all

because internet explorer is teh suck.

I have "A HREF="download_toolbar.htm" target="_self" onClick="parent.home.location.href='download.htm'"" and I am trying to remove the frame part of it
it was taken from some old code of mine
and now the frames no longer exist
so, I assume I can just take out onClick
and keep target="_self" (I just added that)

DARKGirl, you should use onclick rather than onClick as well for validation
all lower case tags in fact

that would be a pain to make them all lowercase
i might run it through an lcase routine later

example123
regex?

could someone kindly tell me why I am getting a "Too much recursion" error whenever I switch back to my browser window on my site

can the onreadystatechange handler take parameters in any way?
blah.onreadystatechange = processthis('sometext');

ultravi01, You're recursing to much and filling up the function call stack. You can rewrite recursive functions to be iterative.
mutilator, Uh, if it's a handler you need to assign a function to it, not the results of a function call.

I'm not sure what recursion is.. do you know of a good resource online or should i just google it

yea but the handler needs to know the name of the xmlhttpreq object
or is there anyother way to identify it other than its name?

function moo(){moo()}

undefined

Wait, no.
function moo(){return moo()}

undefined

(function moo(){return moo()})()

Error: Error: InternalError: too much recursion at line 0: (null)

Whoo
Multiply, Yeah, take an argument in your handler function.
i.e. blah.onreadystatechange = function(evt){console.log(evt)}
Um, e.g.

hm?

Sorry, I meant you.
I think I might disable tab-completion because it always makes me mess up.
mutilator, Um… was that what you were after?

well how would i do what i said above?

mutilator.. what are you doing?

Oh, just reread.

i just joined

Okay blah.onreadystatechange = function(evt){processthis(evt, 'sometext')}

i want to

You lose 'this' inside the event handler that way.

yea.. so do that=this, and then reference via that

But you can use evt.orignalTarget instead.
Oh yeah. Could do that as well.
So blah.onreadystatechange = function(evt){processthis(evt, this, 'sometext')}

perfect

mutilator, Yes?
Whoo

yea
so hmm
coo beans
thanks
was having a problem was firing off too many xmlhttpreq's
each using the same object, just recreating
so i had to do a lot of window[newobj] to crete dynamic names for the req's
just needed to find a way to pass that name to the handler

hello, how to clear the selection in the window?
I tried window.getSelection().collapse(true) but Firefox says not enough arguments
mmh I got what I wanted with removeAllRanges(). Maybe Mozilla-specific

hi
I want to make a script that get the delicous bookmarks from api.del.icio.us
and send that data to another server
seem that this work in ie
but in mozila
when I try to get the data via xmlhttprequest
I get an securty error
how can I fix this?

can you include another javascript file through javascript?
document.body.innerHTML = 'script src="soandso.js"/script'; - is that the only way?
i'm talking firefox only

You can try an XMLHttpRequest to get remote code and eval it…

its cross domain
which is why i have to include a script from the remote domain in the first place :x

Hi people

does javascript support 'static' in functions?

Whats the proper way to refer to a frameset?
MyFrame.location.href = "Test.html";?
Or window.document.MyFrame.location.href = "Test.html";

someone know the name of a good html editor? (WYSIWYG if it's possible, i want it for make div alignments with ease)

Dreamweaver 8.
* CS3

FrontPage.

Kai_wp2 Jafet thanks, i'll get them

Err.

(i'll test both)

http://www.adobe.com/products/dreamweaver/

Both cost money, but Dreamweaver doesn't suck as much.

http://www.runaware.com/microsoft/frontpage2003/
a href="http://www.runaware.com/microsoft/frontpage2003/"http://www.runaware.com/microsoft/frontpage2003//a
a href="a href="http://www.runaware.com/microsoft/frontpage2003/"http://www.runaware.com/microsoft/frontpage2003//a"http://www.runaware.com/microsoft/frontpage2003/"http://www.runaware.com/microsoft/frontpage2003//a/a

Sellout!

Anyway, uh, I don't wanna interupt but, anyone know the answer to my question?
Sellout? :P

Maybe window.Frame

Thanks
LOL

(Frame is frame name)

Does IE support onclick for imgs?

good, i'll beart on mind above points
bear*

NVU is free software, handles WYSIWYG okay, but sucks badly at code editing.

i'm okm with html, i'm only want to do quick div alignments trough WYSIWYG
and i'm not ok with new keyboard, okm=ok :p

open in browser to test cycle?

Actually, you access frames through top and parent.
And why are you coding for IE?

I'm coding for all browsers, its just that this site I made only works in Opera so I'm making it compatible with everyting nhow

I'm not sure if onclick is even standard for images.
Why not wrap the image host in an anchor and use the onclick for that?

Well I mean refering to a frame from the parent. What about "obj = document.getElementByID("MyFrame"); MyFrame.location.href = "Test.php";"?

http://www.quirksmode.org/js/frameintro.html

So "a name="Anchor" onclick="Test();"img/a"

http://google.com/search?q=javascript+frames
After that search query, I have lost all respect for you. Sorry.
The anchor looks ok.

What?? O.0

var scGalleries = new Array();
15 scGalleries[0] = new Array();
16 scGalleries[scGalleries.length - 1][0].imgsrc = "/images/classesgallery/1o1s0.jpg";
I later receive a claim by firefox that scGalleries[0][0] has no properties
when I try to get the .imgsrc out of it

how can i make firefox let me go cross domain?

"Cross-domain"?
What would that mean?

yahoo.com/blah.js does an ajax call to google.com/blah.html

Is there some way to collapse rows and columns in a table such that it will remain centered inside of another element?
I'm right now doing it with setting the style of the td to display:none
but this does not cause the td to stop taking up space

obj = document.getElementById(str); if(obj.style.display=='none'){ obj.style.display='block'; }else{ obj.style.display='none'; }
^ I used that code and it worked fine for me.
Do you want to remove the td?

basically, i want to make it such that the td no longer effects the table geometry
oh!
wait, i see now
i was making a very stupid mistake
sorry to bother, thanks

hi, i'd like to make it so i click on a link on my website, and a little "lightbox" appears saying loading (ontop of the page), then once the whole new page has loaded, it then moves..does anyone know of a script that can do this?

http://www.dustindiaz.com/add-and-remove-html-elements-dynamically-with-javascript/ ok
A dynamic preloader using JS?

if that's what the tech name is…i guess so

http://www.1javastreet.com/vb/scripts/ShowCode.asp?txtCodeId=3536&lngWId=2

thank you, i'll give it a go!

No prob!

dude fuck this cross Domain hosting shit

O.o………
The anchor works but theres a blue box around the image in IE
uThe anchor works but theres a blue box around the image in IE/u

Style the anchors then…
border:0;margin:0;padding:0;

Need help with this javascript
what is wrong with this code
html
head
script
function saveForm(){
if(confirm("Do you want to save changes?")){
document.forms[0].submit();
}
}
window.onbeforeunload=saveForm;
/script
/head
body
a href='dummy.html'Two/a
form name=myform method=post action='dummy.jsp'
input type=hidden name=operation value=save
input type=submit value=submit
/form
/body
/html

Someone needs to kick you.

Jafet were you addressing me

yes, dont paste more than one or two lines

I am sorry

use a pastebin (fi there isnt one inthe topic, than google 'pastebin')
s/than/then/
what form of dyslexia is it when you regularly use the wrong homonym?
cuz i totally have it :/

You appear to have acute AOL syndrome. Consult your physician.

no u r

Thanks!
I gotta go
g2g
Bye!

IE gives me no errors but doesn't show anything, whereas Firefox appends my generated calendar to the body?

AzMoo[w]: The paste 659339 has been copied to http://erxz.com/pb/4054

AzMoo[w]: you should prolly use input type="button"… i dont think anyone uses the button tag

That's not the issue.

k… which calendar app are you using?

I've written my own. It creates a calendar and is supposed to append it to whatever element is passed to the object, but in IE nothing is displayed. It seems to append it, it just doesn't show up.

hmm.. you have your css in order? such as positioning, etc?
sounds like a css position type issue

no CSS at all. It just creates the elements without any styling. Look at the pastebin I posted.

on this.parentNode, set css "position" property to "relative".. then set the calendar container element to "absolute".. maybe try that?
i bet that might fix it

In my test this.parentNode is the document body. Can I set a relative position on that?

in that case, you dont need to, but in all cases you need to set css position of calendar container to absolute

hi, how can i remove li from ul dynamically using js..

AzMoo[w]: try testing on an element other than doc.body

AzMoo[w]: OK, I give in, where's the code?

http://pastebin.ca/659339

AzMoo[w]: The paste 659339 has been copied to: http://erxz.com/pb/4054

AzMoo[w]: Why are the member functions redefined every time a new object is created?

thats just a matter of OOP vs procedural]

because they're part of the object.

message144, AzMoo[w]: No, it's not — put them on the prototype

of the containing element?

AzMoo[w]: No, of the constructor function

as in calendar.prototype ?

E.G. calendar.getDaysInMonth = function() {
Yes

ok yes your right.. misunderstood what you meant

Isn't that what this.getParsedDate = function() is doing?

Incidentally, (strong) convention says that constructor function names begin with a capital letter
No

AzMoo[w]: unless your instanc(iator) will be accessing the methods, then make them static

AzMoo[w]: If you append them to a prototype, they're created once, then reused
AzMoo[w]: If you add them to each instance like you're doing there, they're created again each time

technically they wouldnt be attached to a prototype, they would be static

What?

theres a difference between calendar.foo and calendar.prototype.foo

A "static" function is one that pertains to the "class" as a whole and isn't attached to any single instance
Yes

one is static, and one applies to an instance

But that doesn't have much to do with the problem at hand

so im saying he could do it all statically if he wanted

OK, so I would do var calendar = function() {} calendar.prototype.foo = function() ?

AzMoo[w]: Yes
AzMoo[w]: But it should be Calendar

convention in-house uses firstCharLowerCamelCase

objects can be treated somewhat like arrays (key-value pairs). is it possible to get the first key of the object without resorting to "for (var t in object) {…}" ?

AzMoo[w]: did the css fix your problem?

AzMoo[w]: For constructor functions?

no.

AzMoo[w]: But it uses that for methods.

For objects.

AzMoo[w]: Everything in ECMAScript is an object.

I get that. Nevermind the convention, we'll go with Calendar for now.

Right, so, the problem

not if you dont know the key name

damn. i was hoping i had missed something in the documentation

AzMoo[w]: I suspect the fact that you've tried to encase the constructor code in a block may be the problem

OK, so if I pull the methods out of the instance and put them into the prototype, IE will support it and it will fix the issue?

for(t in foo) break;
then just use foo[t];

AzMoo[w]: ECMA-262 is kind of vague about that, there's no call for it anyway
AzMoo[w]: No, that was a sidetrack because I hate cluttered functions :-)

right, I was just doing it for readability.

AzMoo[w]: It will save you a lot of resource hogging though.

alright, good to know

thanks

AzMoo[w]: And that means you'll have to stop accessing parameters locally, like in generateCalendar(): newParent.appendChild(el)
AzMoo[w]: Store a reference on the instance in the constructor, then access that
AzMoo[w]: You're also missing a "var" or two in createHeadContainer()
AzMoo[w]: If you have multiple instances they'll start overwriting one another.

OK, I'll keep that in mind. I have to go now, but I'll clean it all up and see how I go. Thanks

AzMoo[w]: OK, good luck

Cheers

Hello!
I'm trying to jump the page to an anchor using javascript.
Does anyone know how to do that?

location.href += "#myanchor";

that won't work twice in a row

No

focus()?

var h = location.href; location.href = h.substr(0, h.indexOf("#")) + "#myanchor";

Thank you I thought I might need to do something fancy.

how can i sort multidimensional array

Recurse
And, how do you want the arrays sorted?

like this
for example i have
x[0] = ["4", "sometext1"];
x[1] = ["-3", "sometext2"];
x[2] = ["15", "sometext3"];
i would need it in order of 15, 4, -3
ie x[2], x[0], x[1]
err
yeah, that would be it

b[0] && 1 || -1; });

i have no idea what you wrote there, but let me try

Could be neater, aye

b[0] && 1 || -1; });

hmm
it doesn't work it seems

No?
Darn

no, gimme sec tho
to make example

b[0] && 1 || -1; }); x.toSource();

[["-3", "blah"], ["15", "blah"], ["4", "blah"]]

Mmhm, you're right.

b[0] && 1 || -1; });

{ 0: { 0: -3, 1: blah}, 1: { 0: 15, 1: blah}, 2: { 0: 4, 1: blah}}
b{ 0: { 0: -3, 1: blah}, 1: { 0: 15, 1: blah}, 2: { 0: 4, 1: blah}}/b

tag into the dom with an event from the user. is it possible to submit that data into a POST request. i've tried it with little success… or do i need to insert the tag into a form dom object?

ok this is making my eyes bleed

Ah, strings have a different idea of and

+b[0] && 1 || -1; });

{ 0: { 0: -3, 1: blah}, 1: { 0: 4, 1: blah}, 2: { 0: 15, 1: blah}}

There y'go

let me try

My SpiderMonkey certainly doesn't :-\

i love you Twey

Haha

i've been smashing my head against the wall for last 3 hours

It's just basic use of sort()

i guess, i am javascript inbred, i usually do this kind of stuff in php
but need it in javascript this time so i was stuck bigtime
thank you so much

Heh
Welcome

now i can go to sleep, been a long night

Heh, sleep well, I've missed a couple of nights :-\

thanks, my 3rd sleepless night in a row
gnite

lo. using moo.fx, when i try to assign areas within a map to a variable, they disappear from the browser with no error. any ideas why? http://pastebin.parentnode.org/21277

can anyone help me with my problem?

why doesn't this work:
cells[i].onmouseover = function() { highlight(cells[i]); };

That's probably in a loop, which means that i has changed its value by the time it's executed.
Create a new scope to hold the temporary value of i

are you executing it loop when the Dom's' ready or before?

how would I do that

Doesn't matter

before

cells[i].onmouseover = (function(i) { return function() { highlight(cells[i]); }; })(i);

I just realized what the mistake there is…
but I didn't know how to fix it

Or, in this case you can just use "this"
Which is much easier.

now I'll try Twey's solution
I tried with this before… hmm

cells[i].onmouseover = function() { highlight(this); };
Should be fine
You can even define just one function outside the loop and use the same function for all of them.

http://pastebin.ca/659457 … hey i need help

krupa^: The paste 659457 has been copied to http://erxz.com/pb/4055

does nothing for some reason - lemme try some things
http://pastebin.ca/659462 just won't work

The paste 659462 has been copied to http://erxz.com/pb/4056

Im trying to extract data from a xml-doc. The file has two nodes called object with different ids as attributes. I do var xmlMarkers = re.getElementsByTagName("object"); but get that the length of xmlMarkers is 0, why is this?

anyone know a relatively cross browser way of getting the size/position of text nodes within elements? or is there a way to get text extents given a certain element style or something?

what's a good, free javascript host obfuscator?

Why would you want to obfuscate your Javascript?
Are you ashamed of it?

yes

is there any good obsfuscator for any interpreted language?

Well it's no good! Anyone smart enough to laugh at your code can also de-obfuscate it in a flash.
Of course not

does anyone know how to get my firebug to show xmlhttprequests, it keeps getting disabled whenever I reload a page?

i had thought it'd be like that. it's a nightmare just trying to write one that does a simple variable name replacement

hi all! Is there a javascript specification and tutorial?

Javascript is an implementation of ECMA-262, so you probably want that: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf

Can anyone help me understand what Im doing wrong when parsing my xml-document
I have several nodes named object

There's also http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference

so I put them all in a var with:
var xmlMarkers = re.getElementsByTagName("object");

whats the best way to load and parse XML in javascript?

thanks

As for tutorials, try http://www.howtocreate.co.uk/tutorials/javascript/important

then I try to access the info in a specific node with xmlMarkers[i].getElementsByTagName("id").firstChild.nodeValue

Comments

will it make a problem if i move ibdata1 to a new location then adjust mycnf so that ibdata1 will become of a

fucking mysql 'syntax' error

0') to pastebin, and under it include the new
lucox, and include the describe pun_0948_logupdates;

http://pastebin.com/d2ff97e59

lucox, http://pastebin.com/d35391955 try this

this cannot work …

lucox, why?

because “ are used for marking constraint names not values

hello, is it possible to create a column with a boolean(TRUE/FALSE) value?

and always the same error

well, put the back ticks around the column names and leave the values as they were
lucox, how is it going?

what do you ask? nothing new …

lucox, ok I thought you wanted my help

No, however you can create a TINYINT(1) which will do the same thing however the value will be stored the same size as a TINYINT
Which isn't a major problem

I must have been mistaken…

yes i want

http://pastebin.com/d32ed6ac8
lucox, try this

the same

lucox, what version of mysql hosting are you using?

_Lemon_, ok thanks but as there are no TRUE/FALSE things how do i make it display like TRUE and FALSE checkbox in gtk2:impleList?

5.0.44

TRUE is just a non-zero value where FALSE is zero.

_Lemon_, ah ok

With very beefy hardware, and lots of optimisation, is a MySQL cluster suitable to host an MMORPG backend db?
Or would I be better with something else, if so, what?
I'll be caching data in memory so to reduce the amount of queries

lucox, try this http://pastebin.com/d337b10c

i think delimiter is only for mysql shell, and i have tried it several times

lucox, just humour me, please

always the same

lucox, I am sorry, but I have run out of ideas

me too :-(

lucox, you will have to ask someone more knowledgeable than I am

thanx anyaway

lucox, no probs

people any other help ?

now, has anyone got any idea about my problem. http://pastebin.ca/662122 when it is run at the MySQL 4.1.20 CLI, the created_at_IP column is created as a VARCHAR(15) rather than a CHAR(15). Does anyone know why, please?

If I was to do it, I'd probably use it to substitute hard disk storage (instead of any sort of flat files) that way, your program doesn't have to worry about being fault tolerant, so long as it updates the database - but I have no experience on this sort of level

For a few hundred players, I was thinking something like two replicating clusters of 4 servers.
replicating for zero downtime, switch to the other instantly on the other one having a problem.
Lots of HD writes/reads: BAD

hey
i have a highloaded mysql, the workload is 17++, but it only uses 200meg ram, it has 2GB ram total and is the server is dedicated to mysql

Yes but you won't be able to load from the database as the data is requested, yuo're gonna have to bring a load of it into memory preemptively

how can i speed the things up+???

So what I was suggesting was making sure that when the memory gets edited, updating the database asap!
edit configuration file?!??

PLEASE?!

_Lemon_, thanks a lot i've implemented it(in my perl project) and it works

my my.cnf http://pastebin.ca/662167

Awesome

_Lemon_, what's wrong with loading all basic char data on character select? The client will have to load it's local stuff after that anyway, giving the server a chance to do it's query and prepare it's reponse, in time to send it back for the loading
completion.
How fast is a simple select query that returns 1 row on a very beefy cluster?

Well, if you mean it loads during a client loading scene, then that's what I meant by pre-emptive, and is how it should be done (I assume)
I have a variant of http://blog.evanweaver.com/files/mysql/my.cnf.innodb_1024
It'll load upto 512Mb if I remmeber correctly, you should see what it does differently and tweak yours appropriately
http://blog.evanweaver.com/articles/2007/04/30/top-secret-tuned-mysql-configurations-for-rails
(I don't use rails)

OK, guys, I have worked it out. Apparently, if you have any VARCHAR columns in a table, then it will silently convert any CHAR columns to VARCHAR when you create the table. Do CHAR and VARCHAR CANNOT co-exist within the same table!! That's crazy!

It's not crazy, char is a fixed length which gives you static tables, while varchar gives you dynamic tables.

i am making a perl application acessing a mysql database and there is a TRUE/FALSE column: 0 is false and the rest is true…but i've not implemented yet the NULL entries so i've put the following line: if ($name and $mail and $problem and $resolution)
=that insert the values into the database and else {print "NULL entries are not programmed yet\n"} but if i want to insert 0 in the database it thinks that $res
olution isn't defined and it tells me that null isn't programmed yet…is there a trick to differentiate a NULL entry from 0?

NULL is zero

is not null?
oh differntiate

However mysql hosting differentiates from this and interpretes NULL as "absent" instead of zero

Hello I need someone to help me with a mysql problem…paid service
payment via paypal or ..anything
simple stuff :P
any free lance around ?

State your problem and if someone has a clue, they might help… dun dun dunnn

well my problem is ..I need to reset the mysql root password. I found all in the manual but I cannot reset it ..so I would need someone to login and fix it for me an I pay

ygurugeek, aren't you from china?

Yeah he is.

good luck collecting

xD
Paypal.cn :3

nope
..CH
Switzerland
does it sound as a more..trustable country to you ?

!man reset password

ummm, you shouldn't be having any problems and need to pay - what's the specific problem?

Sorry - I have no idea what function you're talking about! but try http://dev.mysql.com/reset password

!man reset

see http://dev.mysql.com/doc/refman/5.0/en/reset.html

I did that

!man skip grant tables

see http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html

it just doesn't work …because
is on a mac mini box
some commands are different
e.g. doesn't even have mysql console
and by the time I figure it out..I'd rather pay someone pro to do it
ain't a Mysql expert :P

I remember doing this before, it was about startup commands than anything else…

yes
skipping grants table
but

You have to shut it down, then tell it to not load the user tables then you get teh defaults

for me doesn't work spent too many hours on it so I'd rather give access to soemone to do it
yes
been there done that
I did
I am probably too dumb or did something wrong
this is why
I decided to offer $$ for a fix

You've got more money than sense tbph.

Then, with mysql root access you can change the grant tables yourself

yes I do …and more money than time :P
I need to reset
the root password !
so I can't login and change anything
weird enough all worked last night
then …

most people helping out here are here because they want to learn something new, not earn a few bob for helping random people

at a restart looks like an old password took over
okay but I think someone might be interested in helping for money….so I try my luck

Hello.

Shut down mysql. Then start it up with "mysqld_sage –skip-grant-tables –user=root" and it should load without any users/pass
UPDATE mysql.user SET Password=PASSWORD('new_password') WHERE User='root'
Your password should be 'password' (no quotes)

dotgeek:~ davidcosta$ sudo /usr/local/mysql/bin/safe_mysqld –skip-grant-tables –user=root
Starting mysqld daemon with databases from /usr/local/mysql/data
dotgeek:~ davidcosta$ sudo /usr/local/mysql/bin/safe_mysqld –skip-grant-tables –user=root
Starting mysqld daemon with databases from /usr/local/mysql/data
it hands
I tried this
also tried….
with the init file as per manual
when I pass the login command it just hangs (the skip grant)
if you fix it

Just wondering. What would be the best table structure for a directory hierarchy?

would be much faster :P

sudo /usr/local/mysql/bin/safe_mysqld –skip-grant-tables –user=root &

Think all the way through and finish writing before pressing the enter button.

dotgeek:~/Sites/newgeek/vanilla davidcosta$ sudo /usr/local/mysql/bin/safe_mysqld –skip-grant-tables –user=root &
then it hang

table directory with: `directory_id`, `name` then a table file: `file_id`, `directory_id`, `name` ?

[1] 3226
hangs
dotgeek:~/Sites/newgeek/vanilla davidcosta$ Starting mysqld daemon with databases from /usr/local/mysql/data
wait
didn't hang
dotgeek:~/Sites/newgeek/vanilla davidcosta$

…. it wasn't hanging, just running

but didn't do much either hehe
yes

It's now running in the background

but then how can I pass the comman ?
ah
okay :P
and ? :X

But a directory containing a directory?

Now execute your statement

if I type mysql
it tells me command not found
so how do I execute it ( Thanks a lot for your help)

Table directory: `directory_id`, `parent_directory_id` (NULL), `name`
mysqladmin
Or… can't remember the program

okay I know how to run mysqladmin
but how do I run a statement there?

Just a place that will connect and send a query

Wouldn't that be inefficien
t?

Not really, you could probably remove the NULL part as well, as all directories will have a parent directory except for root

id 0 for root?

Yeah, should work
ygurugeek, absolutely can't remember - surely if you're trying to run mysql, you're expecting to run a query at some point?! Do it with that application

Are you sure that wouldn't come out bad in performance?

Otherwise install apache2/php5/phpmyadmin and do it that way
I'm not sure what you're planning to do with it… I can't see anything instantly wrong with it… there is no redundant data?

It's a quiet long story, not too long though.

Well, I'll assume you want to display some sort of directory tree to the user

I feel that you could fix it in no time..I feel that the force is strong in you
bI feel that you could fix it in no time..I feel that the force is strong in you/b

Partially.

Then look up binary trees, it's a common computing concept, try implementing a derivative of that somehow

Binary trees?

and unless you're containing 100,000 directories, I can't see anything going desparately wrong

I LOVE those

Binary trees look, in memory, like a directory tree except each node has only two links, to other nodes (which could be the last)
You've got mysql running with one user as root with no password, all you need to do is login and execute the statement I showed you earlier

I will try again

Your English isn't bad so you could easily use the documentation to finish it off

but my client says mysql is not running

Type ps -A
If you see it in the list then it is running

I'm developing a image uploading system, and I thought it would be a good idea allowing the users to sort their images by folders too, so the URL would become http://www.example.org/images/username/folder/subfolder/image.png

Otherwise you'll have to check the mysql error logs

Or something..

I get you
What you have there is very similar to a forum with boards (directories) within boards and then boards containing topics (files)

0.01 sudo /usr/local/mysql/bin/safe_mysqld –skip-grant-tables

Like Sub-category?

0.00 ps

I implemented that in a very similar way to the tables I suggested before - it works perfectly fine, all queries are doing great too

Ok, thank you for your time.

That means it's running, you're client isn't connecting to it properly then
No problem

via ssh how can I login then?
I mean to execute the query

"mysql –user=root"

I got an idea

Then you can type your statement

is there any book you like ?

Then type \g to execute it
A book? Naaah, I don't need payment :p

mysql works
let me see

You don't realise how close you are to finishing this

can you give me the update command ?

USE mysql; SELECT * FROM user;

UPDATE mysql.user SET Password=PASSWORD('new_password') WHERE User='root'

dotgeek:~ davidcosta$ UPDATE mysql.user SET Password=PASSWORD('1234') WHERE User='root'
-bash: syntax error near unexpected token `('

You still have to be logged into mysql

yes sorry :X

When you type "mysql –user=root" it should bring up a new thingy and look like mysql

ok done
now it just
says

:P
after the statement

safe_mysqld is the actual mysql server, dealing with giving you the data. mysql is the client that connects to the server
Type \G

should I try to connect now ?

You _are_ connected

I mean
with the application which needs to run

Did you type \G
(or was it \g?)
That will send the query you typed out

\G

Did it give you a confirmation or anything??

nope
just

hmmm
UPDATE mysql.user SET Password=PASSWORD('new_password') WHERE User='root'\g
Put that into it…

got a new line thing

;
semicolon

You're 100% positive? Nothing like:
Query OK, 1 row affected (0.00 sec)
1 Changed: 1 Warnings: 0

Write a semicolon there.

semicolon doesn't seem to be a problem… and it should generate an error :s

Write it.
In that new line thing you got.

do you have gtalk ?
is for an open source site
formerly dotgeek.org
PHP forums etc
so
ain't really doing it for bucks either !
I feel is something deeper because no one changed the root pw
and yesterday worked
then I updated the script..the php script
and didn't connect anymore to the server

That's odd.

will engrave your name on the new forum :P
yes is really like…may be there are 2 mysql running or
don't know how the password changed

Do you have a backup?

Then you've probably changed the password the script uses to connect to mysql with…

becase all was fine ..then all of a sudden..bom can't login anymore via admin etc
no
I didn't

ah

100% positive not
ain't so stupid lol even if is hard to believe :P

Where was this php script from? Was it malicious?

Do you have a backuo of your database?

no malicious
was an extension for a foum
I have all the db backup etc

Yeah but it still could have contained bad code if the source was a bit dodgy

If I were you I would remove MySQL completely from the server and set it up again.

sure but
I don't htink bad code
can change mysql root pw !

I'm assuming your php site was connecting with the root user?

yes
was using root user..because we never used mysql on this server so
yes
:X
bad practice

Terrible practice.

When this is sorted, create a new user account without grant access

yes

I would remove the MySQL completely from the server and put it up there again with the backup.

may be I was thinking to erase mysql and re install

Then even if that was bad code in the forum, it won't be able to mess with the mysql user tables :s
Didn't you just say you changed the root pw?

apparently not
cauz I can't connect
wouldn't you ssh ?
I am begging you

You have to restart mysql without the –skip-grant-tables

You don't seem to respond.

I do respond
I tried it all and foesn't work lol

ygurugeek:

there shouldn't be a reason to reinstall, although a backup should be last resort…

I think I am omitting something
may be something stupid

hi! can anybody tell me whats wrong with that statement?
CREATE TABLE `association` (`idassociation` int(10) unsigned NOT NULL auto_increment, `name` varchar(30) NOT NULL default 'asdf', PRIMARY KEY (`idassociation`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT;

_Lemon would you ssh for me ? wouldn't take you much

I use the methods I know to work, instead of inventing others methods with trial and error.

for that I didn't need to come here
reinstall is easy no ?

ha, suppose but it's overkill for this problem
pm me the ssh login then

Yes, it is easy.

what's the problem with it? The error?

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

I did pm you but may be I am in your ignore list :X
_Lemon_:
:P

I… am?
You… are even?

He's not registered at freenode.

I am but with another nick

Non registered users can't PM you unless you allow it.

now should work

CREATE TABLE `association` (`idassociation` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(30) NOT NULL DEFAULT 'asdf') ENGINE = myisam;
?

the problem is was the AUTO_INCREMENT at the end, thx!

np

hello i am doing a current SQL call being http://www.pastebin.ca/662221 but the problem is that group_categories and categories has mutliple match results but it only grabs the first one, i was wondering how i can grab all the results for the
categories
anyone know, its been bugging me for ages

hi people.. anyone there?

hi

What's the SQL command to view what users are added to mysql (and maybe show the privileges, if possible)?
as root

Is it possible to push back the auto-incrementing counter of a table?
I had 100 rows, and deleted 97 of them.
So now it has 1, 2, 3, 86.
I want it to be 1, 2, 3, 4.

ALTER TABLE thetable AUTO_INCREMENT = 5;
and change the 86 to 4

OPTIMIZE TABLE table_name;

oh, I didn't know that existed - that's pretty awesome

hey, i am running a rather big site, but the mysql is really slow how can i find out what bottlenecks the mysql?
it does not use all ram and workload is 17
or server load*

what's a prefix index in MySQL?
if you had a varchar(10) and you would only use the first 4 chars as the index?

hi, is it possible to change mysql db name ?

!man rename

see http://dev.mysql.com/doc/refman/5.0/en/rename-table.html

ummmm

http://dev.mysql.com/doc/refman/5.0/en/rename-database.html

!man rename database

Sorry - I have no idea what function you're talking about! but try http://dev.mysql.com/rename database

I wonder if the bot can get to it

http://dev.mysql.com/doc/refman/5.1/en/rename-database.html
it was added in 5.1.7
"RENAME DATABASE destroys any stored routines or events associated with the original database."
Ouch

rename_database–

if you had a varchar(10) and you would only use the first 4 chars as the index?
is that a prefix index in MySQL?

mmm..
it just create a new db
move table over
drop the old db

it makes sense, then

mysqldump old_db | mysql new_db

hrmm…
what would you gyys say the best way to do replication is?

(ground ball to second base)

haha

http://dev.mysql.com/doc/refman/5.0/en/replication.html

mm..it's not in ubuntu repo yet, 5.1.7

still beta, isn't it?

that's what topic claims.

is the midpoint insertion trategy and LRU used for only MyISAM … or is this for InnoDB as well?

Question. I have the command "SELECT `a`,`b`,`c` FROM `example`;", but say that I want to return those three fields but only when `a` is DISTINCT, how would I do that?

DISTINCT applies to the whole ROW
use GROUP BY `a`

HAVING count(0) = 1

thumbs, GROUP BY was causing certain entries to be ignored when I used it in conjunction with ORDER BY.

that numerical value in quotes refering to a column position in the table?
parens*

it's your only option
or chadmaynard's

count(0) = count(*)

however, I suspect grouping might be faster

any benefit from using count(0)?

I would be placing count(0) after SELECT without listing any of the columns that I want?

i meant GROUP BY a HAVING count(whatever) = 1; - returns a's that are distinct.

no, HAVING goes at the end
ah. Neat trick
so it looks like your only option is grouping.

I'm sure there are no real performance diffs
I'm pretty sure mysql substitutes count(*) to count(0) internally, though

lol

so, in my case, SELECT `a`,`b`,`c` FROM `example` GROUP BY `a` HAVING count(`a`)=1; ?

tias

how could I calculate the size of my non-leaf indexes for one table?

Try it and see, its quicker to type it on your system and try it than wait for one of us to tell you its ok

you ask questions like someone studying for a test.
lol

lol.
I've been reading -a lot-.

for a test?

threnody, I have an interview in two weeks

'what is the meaning of life?' 'how much does god weigh?'

42. No one knows.

so… how could I calculate the size of my non-leaf indexes for one table?

We are changing MySQL server hosts from one computer to another, and replication is involved. Old master (id=1) is still being seen as the replication source by slave (id=3). I've edited the my.cnf on slave to look to new master; what else keeps it looking to the old master?

I'd like to do something like "LOAD INDEX INTO CACHE t1, t2 IGNORE LEAVES;" … but I don't know how big my indexes would be, so I'm trying to figure that out.

Just spotted "CHANGE MASTER …" command in the docs.

I switched to using GROUP BY, but it's ignoring my ORDER BY, instead sorting first by GROUP, and then by ORDER. For instance, I have SELECT * FROM `example` GROUP BY `foo` ORDER BY `bar` DESC, it would return `foo`=2, `bar`=1 before `foo`=1, `bar`=2
I probably did not explain that well, because I'm not certain what is actually causing the problem, I'm sorry.

GROUP BY does not cause the sql engine to ignore ORDER BY
errr
^^
presumably, another factor is mangling your results

I have two columns, one that I'm trying to isolate from duplicates, sorted by the second.
except it needs to sort the second before it starts cutting the duplicates,and it seems to be doing it the other way around.

My replication slave still insists on trying to connect to the old master. CHANGE MASTER did not shift its attention to the new master. What else needs to happen?

if you're doing a group by, you are going to get one value for the associated columns. You can choose which value by using another aggregate function, like max() or min().

threnody, thus why I wanted to use DISTINCT over GROUP BY.

you can't use DISTINCT. Forget about it.

prehaps you want more like '…group by a desc, b asc'

threnody, I can try something like that lemme do that.

if you could tell us in english what results you want, it might help.

I'm a young, dumb American, that might be difficult!

I wonder why you'd admit that fact

i have a very similar query and ordering doesn't work for me either

here's bad news - I'm an old dumb America. It doesn't get better.
group by ordering is a real issue.

american has n on the end. moron.

Well, let me rephase what I want. I have two columns, I want to sort by the second column, returning only unique results from the first column.

you're not the only one. http://forums.mysql.com/read.php?20,134952,134952

if you are only returning a where the count() = 1 then there should only be one b value associated with the group so max() = min() so ordering should work

Well, juding the book by the cover and just reading the title, I can tell that this problem looks the same as mine. I'll give it a read.

Got it — had to add a "master_host=" clause to the "change master" command.

Oh man, his final solution is not easy to extrapolate into my mind.

mydb.sql

when i give this i still get the password prompt
i am giving the password in the command line but it does not take it as an argument it still displays the password prompt

take the space out
-pxxx not -p xxx

in a bash script this works- '…-uroot -p'pwd'…'

chadmaynard!

seekwill!

oh, get a room!

Do you play DTD?

no

We can play multiplayer DTD

thanks

didn't you read?

Playing strip pokim?

ha

I could have predicted that!
hehe

: (

Well, there is PRIMARY and UNIQUE, but what is INDEX for?

to create an ordered set of data that the dbms can search through faster than the unordered set

For example?

um….

So, I'll set everything to INDEX. Wouldn't that be a nice performance boost?

maybe maybe not. Depends on the overhead of the index and if it is useful

Overhead?

is there a way to cap the disk usage a mysql user can use?

Yes.

i'm having a problem with a user taking up all the disk usage on a disk (accidentally)
how?

Well, changing the source always work. But I'm sure there is a better way, and unfortunately, I don't know how.

im trying to create a database to hold details on furniture ranges. i have a table with a list of ranges, i then have a table with a list of products (also has a range id to link it to ranges) the problem i have is each product can have anything from 1 to 40 sub products that i need to record
the dimensions of. has anyone any ideas as to how i could layout this table

set quotas

don't be silly

Could you explain it again with the INDEX thing? I didn't quiet understand.

I'm always silly

what don't you understand Polarina?

The thing it does…
Is it unique?

no

Can it be both?

UNIQUE is INDEX, but with the unique property added

what's a prefix index?

you'd have to set up this user databases physical filesystem files under O.S. cota control.
quota

If I set something to UNIQUE, it is also INDEX. Right?

technically it is just UNIQUE. but yes, UNIQUE indexes are indexed

Ok, thank you.

there is not point in doing UNIQUE(name), INDEX(name). that'd be redundant

anyone?

Ok.

I think I've found the solution, it's in the manual: http://dev.mysql.com/doc/refman/5.0/en/example-maximum-column-group-row.html. Is this what you were looking for?

anyone any ideas about my problem??

Hi all, I had to do a quicj change from server to server so i simply copied all my /var/db/mysql across, How can I make this run on the new server? I am not quite sure how to search for this so if i missed somthing please point in the right direction
Thanks
the files are all MYD and MYI and frm and similar

put it in the datadir and chown to mysql user

will i chown it to the name of the mysql user or to the actual mysql user account?

whatever mysqld runs as

ok thank you
Thank you so much chadmaynard you just saved me from a very angry boss

np

to be fair
chadmaynard++

chadmaynard–

oh, thats a bit annoying
you mean set a quota for there home directory, and change the path of the mysql data to go in there home directory?

I don't think there are bte-control controls under mysql
you could put a trigger to fail insert past a certain number of rows… but that would be work aroundable, I think, and even more annoying
yes.
that is what I meant
no path changing needed, you might just set upa soft link.

hmm
will it work with a softlink?
im not sure it will

dmb_ it should.

by softlink, you mean symlink right?

yes…a soft symlink, as opposed to a hard symlink
the later would nto work accorss filesystems, and myeb would not be subject to teh quota settings.
I willhave to leave now. (and I don't bother switching the nick very much) …
best wishes there!
bbl.

ok

afternoon
I'm looking for an application like pgadminIII but for MySQL… I know about the web-based ones, but any Qt/KDE ones?

gui

GUI tools can be found at http://dev.mysql.com/downloads/gui-tools/5.0.html phpMyAdmin at http://www.phpmyadmin.net/ and even navicat or http://www.webyog.com/en/

thanks

how do i select the latest record added from a table?
is select * from products order by max(timestamp) valid?

Any suggestions on what type of query I should run to get "all birthdays within in the next week" on a DATE column format?

Hi I'm tyring to Query the last 5 selection of a table, any idea on how to achieve that ?

will it make a problem if i move ibdata1 to a new location, then adjust my.cnf so that ibdata1 will become of a fixed size and move it to a new location (and autoextendable ibdata2 will be added in old location)? do i need to take care of ib_logfile's or ib_arch_log in some special way?

what would make mysql still be up, just not take anymore incoming connections? Nothing in the error log about it

Evil things like spiderpig?
I don't know, honest.

anything I can do to find out more about it?

Restart the MySQL server?

that fixes it, yes
but this happens a fwe times a day

Having it restart as a cron job would work.

yes, but no :p

What version are you using?

4.2 iirc

Upgrade, for gods sake!

easier said then done

What's the problem?

There is no 4.2…

sorry
4.1.14

Even worse!

besides, even with backups, doing database upgrades worries me

When it does not accept anymore connections, is the system still responsive?

yep
and existing connections continue to work fine

Installing a never version isn't going to be a permanent decission. You can always go back.

Log in as root, and do a SHOW PROCESSLIST. I bet you have sleeping connections. Those should be disconnected.

crap, just restarted
but next time I'll give it a shot

What connects to the database? PHP?

PHP, python, and a few C++ apps

Make sure you are not using pconnects (especially in PHP)

Hello
I need a help with creating 2 unique columns !!

yea, I guess I could go back to the old version if it fucks up

hi
I am thinking to use a bash script to query my database. I have seen there is shsql shell but I need to be root to install it

echo query | mysql

jbalint but I need to store the return data
I am trying to do something like $RESULT=mysql -u root -ppass database /tmp/query

ok

hey, how would i do something like "SELECT id,COUNT(SELECT something FROM table) FROM othertable"?
is that possible?

why are you trying to do it that way?
why not just do a join?

its a more advanced query of course, but i need something like that
to put a select inside of a count, that possible?

sorry, don't know, doesn't really make sense though
count(column)
not count(query)

yeah i was just wondering if it was possible to put a query in there
guess not
how exactly does JOIN work? i guess understanding that could help :-/

based on data from one table, you join another table with relationships
foreign keys and such

so like

table 1 has "mem_id", table 2 has "comment_mem_id"

Not really foreign keys

SELECT * FROM photos JOIN album_id on album? or something?

sorta
select mem_username FROM members, comments WHERE mem_id=comment_mem_id
or select mem_username FROM members INNER JOIN comments ON mem_id=comment_mem_id
same query

hrrrmmm

joins

http://hashmysql.org/index.php?title=Introduction_to_Joins - For more indepth info: http://dev.mysql.com/tech-resources/articles/mysql-db-design-ch5.pdf

thx

i can't figure out how to get the birthdays from a DATE() column. like, all the birthdays in the weeks 1 week
in the next* 1 week
DATE_FORMAT(minfo_birthday,'%d %m')='25 08' AND DATE_FORMAT(minfo_birthday,'%d %m')='18 08')
but that fails
ah, figured it out
%m%d instead of %d%m

what are the multimodal databases?

in case someone gives a damn :P BENCHMARK(1000000,ENCODE("hello","goodbye")) in debian mysql 5.x amd64 takes 0.41s to complete when using ondemand as cpu governor and 0.36s when using performance as cpu governor
using Q6600 cpu and ddr2 6400 ram

what is ondemand

cpu cooling feature, called "governor" in linux kernel
ondemand means that the cpu will work at it lowest freq until there will be some load and then it will throttle up
in my case using Q6600 2.4ghz cpu that means it will idle at 1.6ghz
but step up to 2.4ghz during crunching

ah

so the diff (0.36s vs 0.41s) is most likely the delay of detect higher load and then delay of stepping up the cpu into 2.4ghz speed
like amd's cool n quiet
using same technique in the linux kernel

I have 2 columns, I want to ORDER BY the 2nd column and then GROUP BY the 1st column. How can I ORDER BY before GROUP BY?

can someone explain why my query always returns ,1 ?
$query = "SELECT `notices_read` FROM `ibf_member_extra` WHERE `id` = ". $id;
there is only 1 row in the database, and the notices_read field is empty
running the query directly through mysql returns nothing, but PHP always sets the value to ,1

TheWikies, select a from (select * from foo order by b) as foo group by a
uTheWikies, select a from (select * from foo order by b) as foo group by a/u
TheWikies, the question is why do you want to do that?

I'm creating my own forum, and so I have a column which is the message ID and the second column is the date.

hwy
i mean hey

the message ID's go 1, 2, 3, etc. I want to sort by the date to display the newest posts, but not to show multiple posts of the same topic.;
ie, not to return multiple message ID's.

if i am selecting addresses from a very simple address database, and I want to select say 20, and I want to make sure all of my selection have different states, how would I do that?
DISTINCT nevermind

I guess I can just create another table, have the topics stored in one, and the messages stored in another. It just seems like I could have combined the two.

that's the way to do it TheWikies :P

using mysql cluster, I have a table that claims not to exist when i use describe, drop table, etc., but claims to exist when I try to create it
http://www.pastebin.ca/662522
5 [ERROR] NDB: failed to setup table nfackler.nuke_groups, error: 723, No such table
any ideas?
no files exist in the datadir for this table

any ideas what may complains about incorrect information in .frm files mean after moving ibdata1 to a different location and adjusting my.cnf accordingly?

hey, I'm trying to add a foreign key, the alter table doesn't give me any errors but the foreign key is not enforced… why?

Kronuz, myisam?

hmm
how can I tell?
probably not
can I convert the tables?
is mysisam slower?
or faster?

Kronuz, i think alter table can to that. myisam gives you the wrong answer faster

SHOW CREATE TABLE

nice
I used describe
hmm
there are no fulltext indexes in InnoDB ?

Correct
You can use an external fulltext engine though

hmm

So I have a bunch of dates in a table, and I want to plot them on a chart. I have too many to have an individual plot point per entry, so I want to group them by some section of time and count how many are in each section and plot that count. Am I on the right track?

yes

So the time frame could be months, or years, but I know I want let's say 40 data points… So maybe I should figure out how many seconds or something is in between my first and last date and divide and then group on that some how

Sembiance, sounds good

Now to actually write the SQL
Hrm.. so take first and last date. Subtract first from last. Divide the difference by the number of segments you want, then do a group on the rows date minus the first date dividide by the result of the difference/segmentCount calc.
Seems like that works

hi all, I have a lot of table-bin.xxx files in /var/lib/mysql, are they some kind of backup informations ? Can I remove the oldest ones safely ?

innodb binary log files, for use in replication and disaster recovery. search the manual for 'master purge' command.

thanks threnody , I didn't know where to look in the manual

http://dev.mysql.com/doc/refman/5.0/en/purge-master-logs.html

those puppies can fill a partition pretty quickly.

excellent, exactly what I was looking for
yep
so, as long as I keep them, I can go back in time and restore previous state of a database , right ?

yes

maybe I hould disable this feature completely then
is that possible ?

you can turn it off, or you can set it to automatically purge after a certain period.

I'd rather turn it off, because I'm already doing diff backups of the system with rdiff-backup

if you're faithfully backing up via some other method…

ok, so "SET SQL_LOG_BIN=0" should do the trick if I understand right

http://dev.mysql.com/doc/refman/5.0/en/binary-log.html

table1=(username, …); table2=(username,stuffA); table3=(username,stuffB) what I want is to create a report that says how many of StuffA and StuffB there are for any given user…
I'm having a hard time trying to visualize what the best way of doing that would be
like, if it was only one Stuff table, I could use group by after a left join… but with two tables…
the only thing I can think of is using nested selects
any other ideas?

might be a design issue.
users, possessions, stuffa, stuffb

??

I did a "PURGE BINARY BEFORE now()" , and yet the files are still there

an extra table linking users to the different stuff types.

threnody, what's the "possessions" for?

the manual says, 'PURGE MASTER LOGS BEFORE '2003-04-02 22:46:26';'

I did also with "MASTER"

threnody, do you think there's a way I can do that query without having to create that fourth table linking the users to the stuffs ?

I cannot, but perhaps another here can think of some multiple join that would accomplish it.

hmm… I can think of two ways of doing it with nested selects

I don't know if this is the place to ask, but with phpmyadmin, there's a "binary log" button, I don't what it's supposed to do, but when I click on it , mysqld start to run wild and do lot of hard disk access, but nothing appears

select table1.username, (select count(*) from table2 where table2.username=table1.username) as StuffA, … from table1;
select username, count(stuff_a), count(stuff_b) from (table1 left join (select username, stuffA AS stuff_a, '' AS stuff_b from table2) using (username)) left join (select username, '' AS stuff_a, StuffB AS stuff_b from table3) using (username);
(oh, and group by)
or rather a union, I think

in your stuff tables, one row per item?

threnody, what do you mean?
one stuff = row
but there are two kind of stuffs (and they both have other different "properties" or columns)
threnody, the tables mostly only have in common the username

well, I usually use linking tables for these sorts of situations, but it might not be for everyone.

(actually only have that in common)
hey, is SELECT … FROM a LEFT JOIN b LEFT JOIN c LEFT JOIN d; the same as SELECT … FROM ((a LEFT JOIN b) LEFT JOIN c) LEFT JOIN d ?

LEFT JOIN a, b, c, d ?

??

brackets confuse everything. Try not to use them.

but is it the same ?

join a table, then join another, then join another, then …

if I have a table with 2 primary keys, what happens if one of those keys is auto_increment?

and what about what hlms said?

ok, I can't remove the log files with purge, I don't understand why, instead I disallowed the log-bin option in my.cnf, so now is that ok to delete the files manually ?

there is no point in joining 4 tables at the same time

why? I suppose it depends

there is no point in joining 4 tables at the same time
besides, a JOIN joins TWO tables at the same time.
!man join

see http://dev.mysql.com/doc/refman/5.0/en/join.html

SELECT id, name, (SELECT COUNT(*) FROM bar WHERE fooid = foo.id) as numbars FROM foo; can that be done without subqueries?

it can

in mysql, if I'm managing files, should I just use the filesystem or store them with mysql
what's the consensus?
with the database I get the added benefit that permissions are easier to enforce

store file *contents* on the DB? don't…

select id, name, count(fooid) as numbers FROM foo inner join bar on fooid = foo.id group by id, name
^^

PovAddict, yeah
is it much much worse?
it's been a pain dealing with File calls in my rails app

storing files in the databased is a TERRIBLE idea

okay
that's the consensus
I will not use the BLOB

performance wise, it'll kill your app.

yeah
I'd better use the tried and true fs…

if I have a table with 2 primary keys, what happens if one of those keys is auto_increment?

I don't think you can have 2 PKs.

sure you can. its called a composite key

a PK made of two columns?

so, is that ok to delete the table-bin.xxxxxx files if I don't use the binary log features anymore ?
I mean manually, I can't make the "purge" command work

im wondering if the auto inc key will start at the default, then just keep going up no matter what.. or if it might start over if the other PK gets changed

Then you'd have a single, composite PK.

now that I think about it, it probably just counts up and up

hmm I'm on a similar question as d03boy

did you see my reply?

yes and thanks; but the PK thing is a different problem

ah.

I have a 'group' column, and an 'id' column; the id has to be actually "id within group"

add a WHERE clause, then

ya thats basically wha ti wanna know
i have a recipe (rid) and the steps within the recipe (step), both primary keys

where id in (…)

i'd like the step to count up starting where the last one left off just for that rid

same

same what?

same as me

I need the same as him the message number has to be "local" to each newsgroup

ok then.

do I need to code that myself instead of using auto_increment?

I'll keep out of it.

we both just have the same question, thast all

http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html
\o/

which section?

see from the second example
"For MyISAM and BDB tables you can specify AUTO_INCREMENT on a secondary column in a multiple-column index."

hello how to restore only one table from bih mysqldump backup? i saw a solution with limiting privileges somwhere, but i cannot find it now

you could extract the statements related to that table, place them in a separate file, and restore that.

i have a question about mysql stored procedures.
i'm getting an error when i attempt to enter my header
DELIMITER //
CREATE PROCEDURE update_charge(
IN p_user_id,
IN p_task_id,
IN p_num_hours,
IN p_charged_date
)
BEGIN
DECLARE v_count_charges int;
DECLARE v_charge_id int;

oh god

SELECT count(*) INTO v_count_charges

PASTEBIN

try http://pastebin.ca or http://pastebin.mysql-es.org

FROM charge
WHERE user_id = p_user_id
AND task_id = p_task_id
AND charged_date = p_charged_date;

0 THEN

UPDATE charges
SET num_hours = p_num_hours,
WHERE user_id = p_user_id

it is 8GB file

AND task_id = p_task_id
AND charged_date = p_charged_date;
ELSE

stop pasting

INSERT INTO charges
(
user_id,
task_id,
num_hours,

try using a pastebin

charged_date
) VALUES (
p_user_id,

kick him already…

p_task_id,

grep it?

p_num_hours,
p_charged_date
);
END IF;

but hwo to edit then

END;
/

END!

sorry

kahotep, pastebin.ca

i meant to only post the header

he can't "stop" without disconnecting

use a text editor?

from his end, he sees he already pasted all

there are binary files

here we see one line per second…

if i have a simple table which has just two columns which are both the primary key, how can i do an insert into that table without risking being told that i have a duplicate primary key?

the dump is binary?

but ok, i will try to recall this from memory

http://pastebin.ca/662609

basically, i want the 'duplicate' error to be swallowed

partially

PovAddict, i still dont see that example.. not sure if im lookin in the righ tplace

thats teh procedure

if the row exists already, good, i don't care - don't want an error though

i've got it :-) http://hashmysql.org/index.php?title=Single_table_restore

here's one with the error on the bottom http://pastebin.ca/662611

ah.

but thanks

(this is for logging IPs against user id's)

http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html
there's two boxes, one showing MySQL commands and one with the result, then three paragraphs, right?

oh, i see it, thanks

interesting stuff starts @ 3rd paragraph

cool

uh - forgot to ask
thanks for the alternative without subqueries but… which one is actually more efficient?

a JOIN is always more efficient.
but please, do benchmark it yourself

I was more asking by curiosity… I may have like a hundred rows

How could i increase @i value for every row? Update cats set position = @i WHERE parent_id = '$parent_id' order by position asc

a JOIN, especially a INNER JOIN on indexed columns, is always faster than a subquery

what idiot was just posting stored procedures in here
i hate those idiots

it was an accident. get over it

those need to be kicked at the 3rd line pasted; not banned, let them join back; but at least that way they stop

get a flood bot in here!

ghm
??

http://mysql.pastebin.com/m77affe2 - there is only one auto_increment column and it IS a key
so what's up with that error?

to make a composite key do I have to do PRIMARY KEY (col1, col2) or can I just put PRIMARY KEY in each of the columns lines

d03boy, the first

mmmmm
what wrong with this query? Update cats set position = (SELECT MAX(position) +1 ) WHERE parent_id = '$parent_id' order by position asc
it produces same positions

the inner select doesn't have FROM
you probably need:
Update cats set position = (SELECT MAX(position) +1 FROM Cats) WHERE parent_id = '$parent_id' order by position asc
any idea on MY error?

You can't specify target table 'cats' for update in FROM clause
ghmm

store the value from SELECT MAX(position) +1 FROM