Options

using(PennyArcade.Forum){Threads.push(ProgrammingThread())}

15758596163

Posts

  • Options
    clsCorwinclsCorwin Registered User regular
    edited May 2010
    No, its a valid query. Also, it is switching on i just fine.

    Also, echoing $result yields: Resource id #4

    clsCorwin on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited May 2010
    clsCorwin wrote: »
    No, its a valid query. Also, it is switching on i just fine.

    Also, echoing $result yields: Resource id #4

    I'd imagine so, it's a MySql query resource.

    I was talking about this:
                    while ($row = mysql_fetch_assoc($result))
                    {
                    ?>
                            <tr>
                            <td><font face="Arial, Helvetica, sans-serif"><?=$row['artist_name']?></font></td>
                            <td><font face="Arial, Helvetica, sans-serif"><?=$row['date_released']?></font></td>
                            </tr>
                    <?
                    }
                    mysql_close();
    

    Change it to:
                    while ($row = mysql_fetch_assoc($result))
                    {
                    ?>
                            <tr>
                            <td><font face="Arial, Helvetica, sans-serif"><? echo $row['artist_name']; ?></font></td>
                            <td><font face="Arial, Helvetica, sans-serif"><? echo $row['date_released']; ?></font></td>
                            </tr>
                    <?
                    }
                    mysql_close();
    

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    Michael HMichael H Registered User regular
    edited May 2010
    So does anyone else read Stack Overflow? I've been finding it really useful and educational, even if I don't have a question to ask. Just skimming the various topics that interest me (they have a great tagging system) offers up tons of information. It's fun to read through the code golf topics, too.

    Michael H on
  • Options
    clsCorwinclsCorwin Registered User regular
    edited May 2010
    Now it takes longer to display nothing =)

    clsCorwin on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited May 2010
    clsCorwin wrote: »
    Now it takes longer to display nothing =)

    I'm actually not convinced the tables/queries are set up right.

    Taking $i = 0 for instance, you have a table called 'Artist' ?

    And then the table Artist has columns with the format: artist_name, date_released?

    All your tables follow this format? Seems really weird to have tons of tables with the same structure/information.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    MKRMKR Registered User regular
    edited May 2010
    Small .NET question:
    Value of '0' is not valid for 'index'.

    The relevant code:
    txtURL.Text = SubURLList[lstFeeds.SelectedItems[0].Index];
                    txtTitle.Text = SubTitleList[lstFeeds.SelectedItems[0].Index];
                    txtFeedContent.Text = SubDescriptionList[lstFeeds.SelectedItems[0].Index];
    

    This is in the event handler that fires when an item is clicked. It works fine on the first click, but the second one causes this exception.

    The lists (SubTitleList and co.) are all List<string>.

    edit: And lstFeeds is a ListView control.

    edit: I tossed a check in there to make sure SelectedItems.Count >= 1 and it works fine now. Any explanation for this? I can only idly speculate.

    MKR on
  • Options
    iTunesIsEviliTunesIsEvil Cornfield? Cornfield.Registered User regular
    edited May 2010
    MKR wrote: »
    Small .NET question:
    Value of '0' is not valid for 'index'.

    The relevant code:
    txtURL.Text = SubURLList[lstFeeds.SelectedItems[0].Index];
                    txtTitle.Text = SubTitleList[lstFeeds.SelectedItems[0].Index];
                    txtFeedContent.Text = SubDescriptionList[lstFeeds.SelectedItems[0].Index];
    

    This is in the event handler that fires when an item is clicked. It works fine on the first click, but the second one causes this exception.

    The lists (SubTitleList and co.) are all List<string>.

    edit: And lstFeeds is a ListView control.
    Just a guess, but if you don't have the ListView set to Multiselect = true, then you might be running into a weird issue where nothing's selected at the moment the click happens. As in the item you clicked the first time has become deselected, the click has occured, but the ListView hasn't caught up to making the new item you've clicked Selected = true. You might try using a SelectionChanged event instead of Click or MouseClick.

    iTunesIsEvil on
  • Options
    MKRMKR Registered User regular
    edited May 2010
    Keyboard users were at the top of my mind when I set the event up, so that's already done. :P

    And now I have a program that is almost functional. Some values are prefilled for testing, but it's easy enough to change it out. But it works, and is a lot more than I was expecting yesterday when I was on the bring of giving up.

    So far this is the most complex application I've attempted.

    MKR on
  • Options
    InfidelInfidel Heretic Registered User regular
    edited May 2010
    clsCorwin wrote: »
    It echos out the correct value of i for each link, but 5 also gives this:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /user/student/mfarrell/public_html/cs4250/query.php on line 92

    This is why I said you need to add error checking after every call. You're getting an error at a previous step but blazing through and then the end result is all you get told is "shit done blown up" instead of something meaningful.

    Infidel on
    OrokosPA.png
  • Options
    NightslyrNightslyr Registered User regular
    edited May 2010
    Infidel wrote: »
    clsCorwin wrote: »
    It echos out the correct value of i for each link, but 5 also gives this:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /user/student/mfarrell/public_html/cs4250/query.php on line 92

    This is why I said you need to add error checking after every call. You're getting an error at a previous step but blazing through and then the end result is all you get told is "shit done blown up" instead of something meaningful.

    Specifically, it sounds as though you're not connecting to the db correctly, or your queries are messed up.

    EDIT: In PHP, you don't use ` in queries. Use ' instead.

    Nightslyr on
  • Options
    DVGDVG No. 1 Honor Student Nether Institute, Evil AcademyRegistered User regular
    edited May 2010
    Another quick iPhone question.

    What the fuck is this control (table thing often used for settings) called?
    83928577.jpg

    EDIT: Nevermind, found it: Grouped Table View

    DVG on
    Diablo 3 - DVG#1857
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited May 2010
    Also called: god, do we really have to use this?
    lots of code to make those worthwhile

    Jasconius on
  • Options
    clsCorwinclsCorwin Registered User regular
    edited May 2010
    bowen wrote: »
    clsCorwin wrote: »
    Now it takes longer to display nothing =)

    I'm actually not convinced the tables/queries are set up right.

    Taking $i = 0 for instance, you have a table called 'Artist' ?

    And then the table Artist has columns with the format: artist_name, date_released?

    All your tables follow this format? Seems really weird to have tons of tables with the same structure/information.

    Yea, we do have those tables with that format. Its for a class, so you know how that goes sometimes.

    clsCorwin on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited May 2010
    I'd get rid of the quotes. They don't help you and they're not there for tables anyways.

    $artist = "SELECT * FROM Artist"

    The fact that the query runs, and the result in HTML actually outputs a whole slew of TD/TRs leads me to believe there's either no data in those rows (unlikely) or the columns don't exist (more likely).

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    clsCorwinclsCorwin Registered User regular
    edited May 2010
    Nightslyr wrote: »
    Infidel wrote: »
    clsCorwin wrote: »
    It echos out the correct value of i for each link, but 5 also gives this:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /user/student/mfarrell/public_html/cs4250/query.php on line 92

    This is why I said you need to add error checking after every call. You're getting an error at a previous step but blazing through and then the end result is all you get told is "shit done blown up" instead of something meaningful.

    Specifically, it sounds as though you're not connecting to the db correctly, or your queries are messed up.

    EDIT: In PHP, you don't use` in queries. Use ' instead.

    Changing `to ' yields:

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /user/student/mfarrell/public_html/cs4250/query.php on line 91

    Ditched the quotes entirely and back to blank screen.

    clsCorwin on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited May 2010
    Get rid of the quotes and do this for me:
                    while ($row = mysql_fetch_assoc($result))
                    {
                           [B][I][U]print_r($row);[/U][/I][/B]
                    ?>
                            <tr>
                            <td><font face="Arial, Helvetica, sans-serif"><?=$row['artist_name']?></font></td>
                            <td><font face="Arial, Helvetica, sans-serif"><?=$row['date_released']?></font></td>
                            </tr>
                    <?
                    }
                    mysql_close();
    

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    clsCorwinclsCorwin Registered User regular
    edited May 2010
    Nightslyr wrote: »
    Infidel wrote: »
    clsCorwin wrote: »
    It echos out the correct value of i for each link, but 5 also gives this:
    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /user/student/mfarrell/public_html/cs4250/query.php on line 92

    This is why I said you need to add error checking after every call. You're getting an error at a previous step but blazing through and then the end result is all you get told is "shit done blown up" instead of something meaningful.

    Specifically, it sounds as though you're not connecting to the db correctly, or your queries are messed up.

    EDIT: In PHP, you don't use` in queries. Use ' instead.

    Changing `to ' yields:

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /user/student/mfarrell/public_html/cs4250/query.php on line 91

    Edit: Heres a print views of that artist query from the phpMyAdmin interface of my database
    SQL result
    
    Host: localhost
    Database: mfarrell
    Generation Time: May 24, 2010 at 12:21 PM
    Generated by: phpMyAdmin 3.2.5 / MySQL 5.1.44
    SQL query: SELECT * FROM `Artist` LIMIT 0, 30 ;
    Rows: 19
    Artist_Id 	Artist_Name 	Artist_Rating
    100000 	Bruce Springsteen 	5
    100001 	Alan Jackson 	4
    100002 	Aerosmith 	3
    100003 	Ludacris 	2
    100004 	The Eagles 	1
    100005 	Poison 	5
    100006 	Motley Crue 	4
    100007 	ABBA 	3
    100008 	Acker Bilk 	5
    100009 	Adam Sandler 	4
    100010 	Alabama 	4
    100011 	Alanis Morissette 	5
    100012 	Alison Krauss + Union Station 	5
    100013 	All-4-One 	2
    100014 	America 	3
    100015 	American Hi-Fi 	4
    100016 	Anderson 	3
    100017 	The Angels 	3
    100018 	Anthrax 	3
    

    clsCorwin on
  • Options
    clsCorwinclsCorwin Registered User regular
    edited May 2010
    bowen wrote: »
    Get rid of the quotes and do this for me:
                    while ($row = mysql_fetch_assoc($result))
                    {
                           [B][I][U]print_r($row);[/U][/I][/B]
                    ?>
                            <tr>
                            <td><font face="Arial, Helvetica, sans-serif"><?=$row['artist_name']?></font></td>
                            <td><font face="Arial, Helvetica, sans-serif"><?=$row['date_released']?></font></td>
                            </tr>
                    <?
                    }
                    mysql_close();
    

    we've got data!

    clsCorwin on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited May 2010
    So, that said, change $row["artist_name"] to $row["Artist_Name"] (case sensitivity, huzzah for programming!).

    And, it appears, there's no date_released column in this table.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    clsCorwinclsCorwin Registered User regular
    edited May 2010
    Figured out another vital part. Forgot case on my table names when I actually want to print them out. Check.

    There is Date_Released for a few different tables. Now that I've got that, I need to switch that for the different fields for each tables.

    Right. Thanks Bowen & Infidel!

    edit: and I'm also confusing my tables. this one has Artist_Rating. Check.

    clsCorwin on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited May 2010
    No problem, my method is more old school debugging. Most of the error checking that's possible (or die kind of stuff) would've completely missed this issue, so it's good to learn how to debug stuff with this method.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited May 2010
    Is there any way in Rails to create a DB model in a text file of some sort and then do a rake afterwards? That way I have the model file to keep track of and edit as necessary.

    All the tutorials (like, all 2 I have read so far), just have you create models in the terminal command, which is annoying if you need a big model, and it's not apparent if the terminal command method even lets you specify relations.

    There must be a sophisticated way of doing this.

    Jasconius on
  • Options
    clsCorwinclsCorwin Registered User regular
    edited May 2010
    bowen wrote: »
    No problem, my method is more old school debugging. Most of the error checking that's possible (or die kind of stuff) would've completely missed this issue, so it's good to learn how to debug stuff with this method.

    Whats the method?

    clsCorwin on
  • Options
    DVGDVG No. 1 Honor Student Nether Institute, Evil AcademyRegistered User regular
    edited May 2010
    Jasconius wrote: »
    Is there any way in Rails to create a DB model in a text file of some sort and then do a rake afterwards? That way I have the model file to keep track of and edit as necessary.

    All the tutorials (like, all 2 I have read so far), just have you create models in the terminal command, which is annoying if you need a big model, and it's not apparent if the terminal command method even lets you specify relations.

    There must be a sophisticated way of doing this.

    /script/generate migration [name] will generate a database migration file for you that you can code using text editor of choice however you want, then call rake db:migrate whenever your ready to commit those changes.

    http://api.rubyonrails.org/classes/ActiveRecord/Migration.html has more information.

    Also: Relationships will be defined in your model class files:
    http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html

    DVG on
    Diablo 3 - DVG#1857
  • Options
    bowenbowen How you doin'? Registered User regular
    edited May 2010
    clsCorwin wrote: »
    bowen wrote: »
    No problem, my method is more old school debugging. Most of the error checking that's possible (or die kind of stuff) would've completely missed this issue, so it's good to learn how to debug stuff with this method.

    Whats the method?

    Outputting various variables throughout the way, checking expected output to see how it plays in. In your case I saw about 20 or so td/trs so I assumed it had gotten to the point where it was looping through the elements, which means that the names of the columns were most likely bad (or there was no data for that column).

    But outputting your variables is a great way to debug, think of it like a rudimentary debugger, without the ability to step-in.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    clsCorwinclsCorwin Registered User regular
    edited May 2010
    Oh yea. cout has been my best friend debugging c++ crap

    clsCorwin on
  • Options
    templewulftemplewulf The Team Chump USARegistered User regular
    edited May 2010
    clsCorwin wrote: »
    Oh yea. cout has been my best friend debugging c++ crap

    I'm a big fan of error_log in PHP. I also set up a custom exception handler that uses error_log, so I don't even have to set up error code for a lot of the stuff I've been doing lately.

    I do have a question, though. I have a page parameter for my url (e.g. index.php?page=home). Is there a guide to RewriteRule for .htaccess files anywhere? Does it use a standardized regex syntax that I can look up?

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • Options
    InfidelInfidel Heretic Registered User regular
    edited May 2010
    Here's an example .htaccess from my 4e site.
    RewriteEngine On
    RewriteRule ^(\d+)$ view.php?id=$1 [L,QSA]
    

    Turns /sheets/1099 into /sheets/view.php?id=1099

    Note that this is under the /sheets/ directory, the pattern matching is relative so it looks for a pure number, no paths.

    L means Last rule (stop processing) and QSA means that it will handle the conversions if any are needed to make it properly escaped as a querystring (which is also what you are interested in right?)

    The pattern stuff itself is pretty straightforward regex as you can see.

    Infidel on
    OrokosPA.png
  • Options
    EndEnd Registered User regular
    edited May 2010
    templewulf wrote: »
    Is there a guide to RewriteRule for .htaccess files anywhere?

    Apache mod_rewrite -- In particular, you probably want to look at the useful examples page.

    It uses pretty typical regular expressions (either PCRE or a subset of PCRE, I forget which). Edit: Looks like it is PCRE.

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • Options
    templewulftemplewulf The Team Chump USARegistered User regular
    edited May 2010
    I kinda assumed it was standard regex, but as all regular expressions look like [strike]insane[/strike] evil chicken scratches to me, I could not tell.

    Thanks, guys!

    templewulf on
    Twitch.tv/FiercePunchStudios | PSN | Steam | Discord | SFV CFN: templewulf
  • Options
    clsCorwinclsCorwin Registered User regular
    edited May 2010
    Ok, so using <form action="adhoc.php" method="get"> in my index.php I get a text box. How is data appended to the url, if say, "Big sky" is entered? Is it <url>?Big+sky ?

    And how would I capture this in my _GET?

    clsCorwin on
  • Options
    MKRMKR Registered User regular
    edited May 2010
    clsCorwin wrote: »
    Ok, so using <form action="adhoc.php" method="get"> in my index.php I get a text box. How is data appended to the url, if say, "Big sky" is entered? Is it <url>?Big+sky ?

    And how would I capture this in my _GET?

    You need some web forms 101:
    http://www.w3schools.com/html/html_forms.asp
    http://www.w3schools.com/php/php_get.asp

    MKR on
  • Options
    clsCorwinclsCorwin Registered User regular
    edited May 2010
    Oh good, I was hoping it would be something simple like just using the name of the form in my $_GET.

    clsCorwin on
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited May 2010
    Someone's gonna have to do a new programming thread.

    The title needs to be in Erlang!

    Jasconius on
  • Options
    clsCorwinclsCorwin Registered User regular
    edited May 2010
    Jasconius wrote: »
    Someone's gonna have to do a new programming thread.

    The title needs to be in Assembly!

    Fixed.

    clsCorwin on
  • Options
    bowenbowen How you doin'? Registered User regular
    edited May 2010
    You're both terrible.

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • Options
    EndEnd Registered User regular
    edited May 2010
    clsCorwin wrote: »
    Jasconius wrote: »
    Someone's gonna have to do a new programming thread.

    The title needs to be in INTERCAL!

    End on
    I wish that someway, somehow, that I could save every one of us
    zaleiria-by-lexxy-sig.jpg
  • Options
    JasconiusJasconius sword criminal mad onlineRegistered User regular
    edited May 2010
    obfuscated c

    Jasconius on
  • Options
    StarfuckStarfuck Registered User, ClubPA regular
    edited May 2010
    quick question for a java noob
    I'm just trying to write some functions to query a SQL Server db, so I looked up some stuff and I'm trying to use the JTDS driver. Downloaded it and dropped the .jar file in C:\Program Files\Java\jre1.6.0_07\lib is that correct?
    Because I get a ClassNotFoundException when I do this
    Class.forName("net.sourceforge.jtds.jdbc.Driver");

    I should probably go grab Head First Java or something, but I'm not doing anything too complicated.

    Starfuck on
    jackfaces
    "If you're going to play tiddly winks, play it with man hole covers."
    - John McCallum
  • Options
    clsCorwinclsCorwin Registered User regular
    edited May 2010
    Jasconius wrote: »
    obfuscated c

    clsCorwin on
Sign In or Register to comment.