jordanwb
Members-
Posts
560 -
Joined
-
Last visited
Everything posted by jordanwb
-
TBH I have no idea which subforum this should go under so I'm putting it here. I'm working on a cross platform C application that uses among other things the MySQL C connector. MySQL doesn't give an installer that I can use with mingw so I have to compile it myself which isn't a problem. However I can't get cmake to configure it since every test fails. This is my configure log: http://pastebin.com/uAz4PbXv I don't know what kind of info is needed to help solve the issue so let me know. Thanks in advance
-
Vuze? I think that's the name of it
-
I'm going to cut straight to the chase, this is my function: void client_job_results (client *c, json_object *obj) { char *tripcode_insert_query = "INSERT INTO tah_tripcodes VALUES ('', ?, ?, ?, ?)"; int job_id, results_count; unsigned long tripcode_len = 10; MYSQL_STMT *tripcode_stmt = mysql_stmt_init(conn); MYSQL_BIND tripcode_params[4]; mysql_stmt_prepare(tripcode_stmt, tripcode_insert_query, strlen(tripcode_insert_query)); memset (tripcode_params, 0, sizeof (tripcode_params)); json_object *jobs_array = json_object_object_get (obj, "jobs"), *job, *results_array, *result_pair; char *password, *tripcode, *utf8_password_orig, *salt = alloca(3), *c_password = alloca (9), *des_result = alloca (14), *utf8_password = alloca (20); // is 20 enough? memset (utf8_password, 0, 20); size_t sjis_pass_len; size_t utf8_pass_len; if (jobs_array == NULL) return; iconv_t cd = iconv_open ("UTF8", "SHIFT_JIS"); for (int i = 0; i < json_object_array_length (jobs_array); i++) { job = json_object_array_get_idx (jobs_array, i); if (job == NULL) { continue; } results_array = json_object_object_get (job, "results"); results_count = json_object_array_length (results_array); if (results_count == 0) continue; job_id = json_object_get_int (json_object_object_get (job, "job-id")); if (job_id == 0) { continue; } for (int j = 0; j < results_count; j++) { result_pair = json_object_array_get_idx (results_array, j); password = json_object_get_string (json_object_object_get (result_pair, "password")); tripcode = json_object_get_string (json_object_object_get (result_pair, "tripcode")); // check to make sure password is correct make_correct_password (password, c_password); make_salt (c_password, salt); DES_fcrypt (c_password, salt, des_result); if (strcmp (des_result + 3, tripcode) != 0) { printf ("Client gave invalid password/tripcode pair; claimed \"%s\" gave \"%s\", but got \"%s\" as a result.\n", password, tripcode, des_result + 3); continue; } // // convert to unicode sjis_pass_len = strlen (password); utf8_pass_len = sjis_pass_len * 2; utf8_password_orig = utf8_password; if (iconv (cd, &password, &sjis_pass_len, &utf8_password, &utf8_pass_len) == -1) { printf ("iconv could not convert password. Error is: %s\n", strerror(errno)); continue; } utf8_pass_len = strlen(utf8_password_orig); // tripcode_params[0].buffer_type = MYSQL_TYPE_LONG; tripcode_params[0].buffer = (void*)&job_id; tripcode_params[1].buffer_type = MYSQL_TYPE_STRING; tripcode_params[1].buffer = (void*)utf8_password_orig; tripcode_params[1].length = &utf8_pass_len; // this param is the number of bytes used in the buffer (# of single byte chars) tripcode_params[2].buffer_type = MYSQL_TYPE_STRING; tripcode_params[2].buffer = (void*)tripcode; tripcode_params[2].length = &tripcode_len; tripcode_params[3].buffer_type = MYSQL_TYPE_LONG; tripcode_params[3].buffer = (void*)&(c->user_id); mysql_stmt_bind_param(tripcode_stmt, (MYSQL_BIND *)&tripcode_params); mysql_stmt_execute (tripcode_stmt); } } iconv_close (cd); mysql_stmt_free_result (tripcode_stmt); } When the program reaches mysql_stmt_bind_param the program crashes and I don't know why. iconv does properly convert the shift_jis strings to UTF8 and the program crashes only when I try to insert unicode characters into the table.
-
I'm writing a program in C which requires MySQL. I wrote a little test program to make sure I know how to use the API. The problem is a keep getting a segmentation fault when I call mysql_num_fields on line 23: #include <stdio.h> #include <mysql/mysql.h> int main (int argc, char **argv) { mysql_library_init(0, NULL, NULL); MYSQL *database = mysql_init (NULL); if (mysql_real_connect (database, "127.0.0.1", "root", "", "my_database", 0, NULL, 0) == NULL) { return 1; } char *query = "SELECT * FROM my_table"; int result = mysql_query (database, query); MYSQL_RES *res = mysql_store_result (database); // do stuff with result unsigned int num_fields = mysql_num_fields(res); MYSQL_ROW row; while (row = mysql_fetch_row(res)) { unsigned long *lengths; lengths = mysql_fetch_lengths(res); for(int i = 0; i < num_fields; i++) { printf("[%.*s] ", (int) lengths[i], row[i] ? row[i] : "NULL"); } printf("\n"); } mysql_free_result(res); mysql_close (database); mysql_library_end(); return 0; }
-
get list of categories, and a random item from each category
jordanwb replied to jordanwb's topic in MySQL Help
That'll work, thanks. On a related note, where does "c" and "i" come from? -
get list of categories, and a random item from each category
jordanwb replied to jordanwb's topic in MySQL Help
Yes I did, see picture of results: http://img405.imageshack.us/img405/8157/27243565.png The query returns every record in gd_gallery_images and lists the same single record in gd_gallery_categories twice. There should be only one result, the single row from gd_gallery_categories and either one of the two records in gd_gallery_images. -
get list of categories, and a random item from each category
jordanwb replied to jordanwb's topic in MySQL Help
For each record in gd_gallery_categories there will be one or more records in gd_gallery_images associated with that record in gd_gallery_categories. For each record I read from gd_gallery_categories, I want to get one random record from gd_gallery_images associated with that record. -
get list of categories, and a random item from each category
jordanwb replied to jordanwb's topic in MySQL Help
Thanks for replying, No that won't work. I want to get each record from gd_gallery_categories and also get one random record from gd_gallery_images in the category. The records returned from gd_gallery_categories would be ordered by gallery_cat_id in descending order. -
I have the following two tables: gd_gallery_categories, CREATE TABLE `gd_gallery_categories` ( `gallery_cat_id` int(11) NOT NULL AUTO_INCREMENT, `gallery_name` varchar(64) DEFAULT NULL, `gallery_description` varchar(45) DEFAULT NULL, PRIMARY KEY (`gallery_cat_id`) ) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 gd_gallery_images, CREATE TABLE `gd_gallery_images` ( `gallery_image_id` int(11) NOT NULL AUTO_INCREMENT, `gallery_cat_id` int(11) DEFAULT NULL, `gallery_image_name` varchar(64) DEFAULT NULL, `gallery_image_path` varchar(64) DEFAULT NULL, PRIMARY KEY (`gallery_image_id`) ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 What I want to do is get all the categories in gd_gallery_categories and for each category also retrieve a random image associated with that category in the same row. The value stored in gd_gallery_images.gallery_cat_id is the category id stored in gd_gallery_categories.gallery_cat_id
-
I have the following file structure: test.py test/ __init__.py foo.py __init__.py is empty foo.py has one method declaration: def foo(): print "Hello" test.py has this: test = __import__("test") The "test" module loads fine, but I don't know how to get to the foo() method. I've tried this: test = __import__("test") test.foo = __import__ ("test.foo") test.foo.foo() but when I run the script I get this error: Traceback (most recent call last): File "test.py", line 3, in <module> test.foo.foo() TypeError: 'module' object is not callable
-
I'm writing a Java app in BlueJ which will be platform independent. In my working directory I have an Images folder which contain 5 png images. When I'm working with relative paths do I use \\ or /? This is what I have: this.new_project = new JMenuItem("New Project", new ImageIcon ("Images/document-new.png")); this.new_project.addActionListener (this); this.open_project = new JMenuItem("Open Project", new ImageIcon ("Images/document-open.png")); this.open_project.addActionListener (this); this.save_project = new JMenuItem("Save Project", new ImageIcon ("Images/document-save.png")); this.save_project.addActionListener (this); this.save_project_as = new JMenuItem("Save Project As", new ImageIcon ("Images/document-save-as.png")); this.save_project_as.addActionListener (this); this.quit = new JMenuItem("Quit", new ImageIcon ("Images/system-log-out.png")); this.quit.addActionListener (this); If I have BlueJ run the main(String[]) method on Windows, it works. On linux it works when I use the jar file, but on Windows it doesn't. If I swap the / for \\ it does not work on either OS.
-
I'm trying to use sqlite with a service I'm writing in C#. I'm trying to create a table like so: CREATE TABLE users ( player_id INTEGER PRIMARY KEY, player_screenname CHAR(15) ); I'm getting an ambiguous #3115 error. I'm using SQLite Admin which is an Adobe AIR app.
-
On this page: http://ca2.php.net/manual/en/datetimezone.listidentifiers.php there is the following code snippit: <?php $timezone_identifiers = DateTimeZone::listIdentifiers(); for ($i=0; $i < 5; $i++) { echo "$timezone_identifiers[$i]\n"; } ?> With the following output: Africa/Abidjan Africa/Accra Africa/Addis_Ababa Africa/Algiers Africa/Asmera But when I run it I get different results: localtime Zulu WET W-SU Universal Why do I get different results? I'm running Php 5.2.10 on Ubuntu 9.10
-
[SOLVED] Dynamic content does not show up in IE (what else is new?)
jordanwb replied to jordanwb's topic in Javascript Help
Okay I got everything working for IE7+. I hope. Thanks guys. -
[SOLVED] Dynamic content does not show up in IE (what else is new?)
jordanwb replied to jordanwb's topic in Javascript Help
Okay two things. I cannot put a little circle in the radio box group (mounting) and when I click "Submit" I get a runtime error: Line 339 Error '0.checked' is null or not an object if (quote_form[i+"[mount]"][0].checked == false && quote_form[i+"[mount]"][1].checked == false) { -
[SOLVED] Dynamic content does not show up in IE (what else is new?)
jordanwb replied to jordanwb's topic in Javascript Help
Okay cool. I'll upload the new .js file and see if works on the real site. -
[SOLVED] Dynamic content does not show up in IE (what else is new?)
jordanwb replied to jordanwb's topic in Javascript Help
Okay cool it works. Does the Ajax look okay for IE7+? If you're accessing by dev server (http://99.224.34.94) then yeah it'll be a little slow. -
[SOLVED] Dynamic content does not show up in IE (what else is new?)
jordanwb replied to jordanwb's topic in Javascript Help
All right I changed it and I'll try it on IE in a bit. I see the "JavaScript Best Practices" topic so I'll take a look at that. -
[SOLVED] Dynamic content does not show up in IE (what else is new?)
jordanwb replied to jordanwb's topic in Javascript Help
Okay I put the tbody tags and it's slightly less broken than before. The tables show up but the "Click to Add Blind" link does not work, neither does the "[?]" link beside mounting. The copy I'm working on can be accessed on my local server: http://99.224.34.94/~jordanwb/rainbow/Quote Plus the buttons and the "Click to add blind" link are being aligned to the left instead of center and right, plus colspanning is being ignored. -
[SOLVED] Dynamic content does not show up in IE (what else is new?)
jordanwb replied to jordanwb's topic in Javascript Help
All right I put in the tbody tags on my development copy and I'll see if it works on IE when I get on my Windows box tomorrow morning. I hope that fixes the "problem". -
[SOLVED] Dynamic content does not show up in IE (what else is new?)
jordanwb replied to jordanwb's topic in Javascript Help
So it would be like this: <table> <tbody> <tr> <td> </td> </tr> </tbody> </table> -
[SOLVED] Dynamic content does not show up in IE (what else is new?)
jordanwb replied to jordanwb's topic in Javascript Help
The form does not display. I made it with Javascript because users had usability issues with my previous version. I'll modify the code I wrote to have the curly braces of the same line as the function name. *Edit* I put the curly braces on the same line as the function names and it still won't work. -
I made a Javascript script that makes a quote form. It works perfectly in Firefox as I expected. I try it in IE7 and the damn thing doesn't work (Why'd I expect it would?) I've installed the Script Debugger and no javascript seems to fail. Linky I don't care if it doesn't work in IE6 or older. I really don't know what to check. I wrote the quote.js file, the scripts.js file was auto-generated by Artisteer. I have a div that contains a "Please enable JS" which is removed successfully by IE.
-
[SOLVED] When path starts with admin go there
jordanwb replied to jordanwb's topic in Apache HTTP Server
RewriteRule ^admin/?(.*)$ admin.php [L] works. Thanks corbin and cags. -
[SOLVED] When path starts with admin go there
jordanwb replied to jordanwb's topic in Apache HTTP Server
Okay so the css works now, but http://99.224.34.94/~jordanwb/jscm/admin still does not go to /~jordanwb/jscm/admin.php .htaccess Options +FollowSymlinks RewriteEngine On RewriteBase /~jordanwb/jscm RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^admin/?(.+)$ admin.php [L] RewriteCond %{SCRIPT_FILENAME} !-d RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^.*$ index.php