What, exactly, is wrong with his syntax and if there is how can I change
it so it will run?
Hi Micah,
I think that you got the code form part 2 of the tutorial 1 by
clicking on
the “click to expand” link. For some reason, the code on that page is
quite
messed up – for example, notice the lack of backslashes: the ns at
the
end of some of the strings should be \n, which is the escape sequence
for
newline.
The downloadable script file 2 looks OK (based on a quick visual
inspection using Vim). Try downloading it and see if it actually works.
Okay. At least now the script runs…unsuccessfully, but it runs.
I had to add require ‘rubygems’ at the top because it wasn’t recognizing
‘mysql’.
Now it’s getting as far as line 11 (yea!!!)…
…where it craps out on this line.
borderDB = Mysql::new(‘localhost’, ‘root’, ‘proot’, ‘dbname’)
(not my real proot, nor db name)
and it gives me:
…/…/Developer/usr/bin/gen_encpolygons.rb:11:in new': Access denied for user 'root'@'localhost' (using password: YES) (Mysql::Error) from ../../Developer/usr/bin/gen_encpolygons.rb:11:ingenerate_js_border_overlay’
from …/…/Developer/usr/bin/gen_encpolygons.rb:95
(Yeah, I really need to fix my $PATH)
I’ve checked Mysql, and I don’t have any problem connecting. Could it be
a port issue? I’m running MAMP, and it uses a non-standard port (8889)
for Mysql, but I haven’t had any other problems connecting to it via
Ruby on the command line.
Is this a Mysql issue, or a Ruby issue?
Thanks again for the help, and for putting up with a desperate noobie.
borderDB = Mysql::new(‘localhost’, ‘root’, ‘proot’, ‘dbname’)
(not my real proot, nor db name)
and it gives me:
./…/Developer/usr/bin/gen_encpolygons.rb:11:in `new’: Access denied
for user ‘root’@‘localhost’ (using password: YES) (Mysql::Error)
This is purely a MySQL permissions issue, nothing to do with your Ruby
code. You’re connecting to the MySQL server just fine, but the user and
password you’re trying to use is being denied access. Use your favorite
MySQL admin tool to be sure that you’re using the correct password for
the user ‘root’, and that ‘root’ can log in from ‘localhost’.
I fixed the connection. Have everything installed properly (as far as I
can tell - gem list gives me the whole bundle including: mysql (2.8.1)).
MySQL working fine.
So now I get this error when trying to run the script from a shell:
Command:
$ ruby ./Desktop/gen_encpolygons.rb
Returns:
./Desktop/gen_encpolygons.rb:11:in initialize': wrong number of arguments (4 for 0) (ArgumentError) from ./Desktop/gen_encpolygons.rb:11:innew’
from ./Desktop/gen_encpolygons.rb:11:in `generate_js_border_overlay’
from ./Desktop/gen_encpolygons.rb:95
I’ve googled extensively for similar argument errors, and I’m not
finding any good matches (or solutions).