Daily Archives

Articles indexed Friday April 16 2010

Page 6/120 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Binding a null variable in a PreparedStatement

    - by Paul Tomblin
    I swear this used to work, but it's not in this case. I'm trying to match col1, col2 and col3, even if one or more of them is null. I know that in some languages I've had to resort to circumlocutions like ((? is null AND col1 is null) OR col1 = ?). Is that required here? PreparedStatement selStmt = getConn().prepareStatement( "SELECT * " + "FROM tbl1 " + "WHERE col1 = ? AND col2 = ? and col3 = ?"); try { int col = 1; setInt(selStmt, col++, col1); setInt(selStmt, col++, col2); setInt(selStmt, col++, col3); ResultSet rs = selStmt.executeQuery(); try { while (rs.next()) { // process row } } finally { rs.close(); } } finally { selStmt.close(); } // Does the equivalient of stmt.setInt(col, i) but preserves nullness. protected static void setInt(PreparedStatement stmt, int col, Integer i) throws SQLException { if (i == null) stmt.setNull(col, java.sql.Types.INTEGER); else stmt.setInt(col, i); }

    Read the article

  • NSArray/NSMutableArray : Passed by ref or by value???

    - by wgpubs
    Totally confused here. I have a PARENT UIViewController that needs to pass an NSMutableArray to a CHILD UIViewController. I'm expecting it to be passed by reference so that changes made in the CHILD will be reflected in the PARENT and vice-versa. But that is not the case. Both have a property declared as .. @property (nonatomic, retain) NSMutableArray *photos; Example: In PARENT: self.photos = [[NSMutableArray alloc] init]; ChildViewController *c = [[ChildViewController alloc] init ...]; c.photos = self.photos; ... ... ... In CHILD: [self.photos addObject:obj1]; [self.photos addObject:obj2]; NSLog(@"Count:%d", [self.photos count]) // Equals 2 as expected ... Back in PARENT: NSLog(@"Count:%d", [self.photos count]) // Equals 0 ... NOT EXPECTED I thought they'd both be accessing the same memory. Is this not the case? If it isn't ... how do I keep the two NSMutableArrays in sync?

    Read the article

  • asp:GridView ImageField DataImageUrlField - specifying multiple fields?

    - by Jason Jong
    I know I can use asp:TemplateField for this, but using the standard asp:BoundField or asp:ImageField in the asp:GridView, is it possible to specify multiple fields and use them in the FormatString field as {0} {1} {2} etc... For example <asp:ImageField DataImageUrlField="ProfileImageId,UserGuid" DataImageUrlFormatString="img-profile.ashx?uid={0}&pid={1}" /> I've always pondered on this. This would be much neater than using asp:TemplateField

    Read the article

  • What is this dm-0 device?

    - by Jeff Shattock
    While poking around trying to figure out why a Linux - Linux file transfer is running slower than I think it should, I stumbled across something I'm not familiar with. /dev/dm-0 seems to be my bottleneck, but I have no idea what it is. On my destination server, the iostat command shows a device at the bottom, /dev/dm-0, as being 100% utilized. This server has 6 disks in a mdadm raid5 set, with LVM running on top of it. Each of the underlying disks are sitting around 50% util. The transfer is writing to a logical volume located on this raidset. What is this /dev/dm-0 thing? Once I know what it is, maybe I can find how to increase its speed, or at least understand why its the speed that it is.

    Read the article

  • Problem building PHP extension module

    - by tixrus
    I'm trying to get GD into my PHP. So I compiled it, made php.ini point to it, restarted apache etc. But no GD. So in apache error log it says PHP Warning: PHP Startup: gd: Unable to initialize module\nModule compiled with module API=20060613\nPHP compiled with module API=20090115\nThese options need to match\n in Unknown on line 0 So a bit of googling says I should not use the phpize I have before configuring and making these. I should use a new one called phpize5. I surely don't have any such thing. Unless its packed up inside something else in my php5.3. distro. Where do you get it. In Ubuntu I could just run sudo apt-get install php-dev, (apparently) and it would just appear by magic. At least that's what the webpage said. Unfortunately I am running MacOSX version Leopard. How can I build this GD module so that it will match the API number in my PHP?

    Read the article

  • Completely bizarre Firefox CSS bug

    - by Jason
    I've been doing front end development for a long time, and I have NEVER come across a bug like this before... Save the following HTML to a file and view it in Firefox (mine is 3.6.3): <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> body { font-family: Helvetica, Sans-Serif;} h2 {font-weight: normal;} </style> </head> <body> <h2>Some normal text <strong>some bold text</strong> weird huh?</h2> </body> </html> If you don't want to give it a shot the output is like your cat walked across your keyboard while character map was turned on, except in the strong tags. I feel like this may be a font issue? When I get rid of font-weight: normal it goes back to normal, but I don't want everything to be bolded in my h2... Anyone have any ideas? More importantly, is anyone able to reproduce this?? Thanks.

    Read the article

  • php import to mysql hosted on godaddy

    - by julio
    Yeah, I know! It's not my choice. I am doing a large data import using a PHP script into a mysql DB hosted on godaddy. It seems their mysql connection gets killed every few hours regardless of what work it's doing. Their tech support is useless, and I've exhausted myself writing attempted workarounds. Right now, I'm trying to do a mysql_ping every few minutes, and if the ping returns false, I attempt to open up a new db connection. My script (which takes many hours to complete), keeps failing with the very unhelpful message of "mysql server has gone away". I understand mysql trying to close a connection that's been open too long, but the connection is not idle-- it's busy basically the whole time, and with the pings I've written in, it should not be idle longer than 5 minutes at most at any time. (These same scripts work with no errors on Amazon AWS servers, my local servers, etc.) Any help most appreciated! I'm about to give up.

    Read the article

  • PHP & MySQL username submit problem

    - by peakUC
    I want to allow users to either have there username field empty at any time but I get the username error message Your username is unavailable! how can I correct this problem? Here is the PHP code. if(isset($_POST['username'])) { $u = "SELECT * FROM users WHERE username = '$username' AND user_id <> '$user_id'"; $r = mysqli_query ($mysqli, $u) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($mysqli)); if (mysqli_num_rows($r) == TRUE) { // Unavailable. echo '<p class="error">Your username is unavailable!</p>'; $username = NULL; } else if(mysqli_num_rows($r) == 0) { // Available. $username = mysqli_real_escape_string($mysqli, $purifier->purify(htmlentities(strip_tags($_POST['username'])))); } }

    Read the article

  • Emacs under Windows and PNG files

    - by Leo Alekseyev
    Would anyone have any pointers on getting PNG images to display in Emacs 23 under Win32?.. I have installed the gnuwin32 set of utilities, including libpng and zlib; C:\Program Files\GnuWin32\bin is in path. JPG files started working but not PNGs. I'd appreciate any hints on getting this to work.

    Read the article

  • WCF: SecurityNegotiationException when using client

    - by bradhe
    So I've been trying to set up certificate authentication for my clients and services. The eventual goal is to partition data based on the certificate a client connects with (i.e. the certificate becomes their credentials in to the greater system and their data is partitioned based on these credentials). I have been able to set it up successfully on both the client and the server side. I have created a certificate and a private key, installed them on my computer, and set up my server such that 1) it has a certificate-based service credential and 2) if a client connects without providing a certificate-based credential an exception is thrown. What I then did was create a simple client and add a certificate credential to the configuration and try to call a simple operation on the service. It looks like the client connects OK, and it looks like the certificate is accepted by the server, but I do get this: SecurityNegotiationException: "The caller was not authenticated by the service." That seems rather ambiguous to me. Note that I am using wsHttpBinding, which supposedly defaults to Windows auth for transport security...but all of these processes are being run as my user account as I'm running in my debug environment. Here is my server configuration: <system.serviceModel> <bindings> <wsHttpBinding> <binding name="MyServiceBinding"> <security mode="Message"> <transport clientCredentialType="None"/> <message clientCredentialType="Certificate"/> </security> </binding> </wsHttpBinding> </bindings> <services> <service behaviorConfiguration="MyServiceBehavior" name="MyService"> <endpoint binding="wsHttpBinding" bindingConfiguration="MyServiceBinding" contract="IMyContract"/> <endpoint binding="mexHttpBinding" address="mex" contract="IMetadataExchange"> <identity> <dns value="localhost"/> </identity> </endpoint> </service> </services> <behaviors> <serviceBehaviors> <behavior name="MyServiceBehavior"> <serviceMetadata httpGetEnabled="true" policyVersion="Policy15" /> <serviceDebug includeExceptionDetailInFaults="false" /> <serviceCredentials> <serviceCertificate storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName" findValue="tmp123"/> </serviceCredentials> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> Here is my client config -- note that I'm using the same cert for the client that I use on the service: <system.serviceModel> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_IMyService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/> <security mode="Message"> <!--<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>--> <message clientCredentialType="Certificate" negotiateServiceCredential="true" algorithmSuite="Default"/> </security> </binding> </wsHttpBinding> </bindings> <client> <endpoint address="http://localhost:50120/UserServices.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService" behaviorConfiguration="IMyService_Behavior" contract="UserServices.IUserServices" name="WSHttpBinding_IMyService"> <identity> <certificate encodedValue="Some RSA stuff"/> </identity> </endpoint> </client> <behaviors> <endpointBehaviors> <behavior name="IMyService_Behavior"> <clientCredentials> <clientCertificate storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName" findValue="tmp123"/> </clientCredentials> </behavior> </endpointBehaviors> </behaviors> </system.serviceModel> Can anyone please help provide some insight as to what might be up here? Thanks,

    Read the article

  • Paypal IPN Handler for Cart

    - by kimmothy16
    Hey everyone! I'm using a Paypal add to cart button for a simple ecommerce website. I had a Paypal IPN handler written in PHP that was successfully working for 'Buy it Now' buttons and purchasing one item at a time. I would run a database query each time to update the store's inventory to reflect the purchase. Now I'm upgrading this store to a 'cart' version so people could check out with multiple items at a time. Would anyone be able to tell me, in general, how my IPN handler would need to be altered to accommodate this? I'm unsure of what a response from Paypal looks like for a cart purchase as opposed to a buy it now purchase. Thanks, any help or examples of working IPN cart scripts would be very appreciated! My current code is below.. // Paypal POSTs HTML FORM variables to this page // we must post all the variables back to paypal exactly unchanged and add an extra parameter cmd with value _notify-validate // initialise a variable with the requried cmd parameter $req = 'cmd=_notify-validate'; // go through each of the POSTed vars and add them to the variable foreach ($_POST as $key => $value) { $value = urlencode(stripslashes($value)); $req .= "&$key=$value"; } // post back to PayPal system to validate $header .= "POST /cgi-bin/webscr HTTP/1.0\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; // In a live application send it back to www.paypal.com // but during development you will want to uswe the paypal sandbox // comment out one of the following lines $fp = fsockopen ('www.sandbox.paypal.com', 80, $errno, $errstr, 30); //$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30); // or use port 443 for an SSL connection //$fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30); if (!$fp) { // HTTP ERROR } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); if (strcmp ($res, "VERIFIED") == 0) { $item_name = stripslashes($_POST['item_name']); $item_number = $_POST['item_number']; $item_id = $_POST['custom']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; //full amount of payment. payment_gross in US $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; //unique transaction id $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; $size = $_POST['option_selection1']; $item_id = $_POST['item_id']; $business = $_POST['business']; if ($payment_status == 'Completed') { // UPDATE THE DATABASE }

    Read the article

  • Video Synthesis - Making waves, patterns, gradients...

    - by Nathan
    I'm writing a program to generate some wild visuals. So far I can paint each pixel with a random blue value: for (y = 0; y < YMAX; y++) { for (x = 0; x < XMAX; x++) { b = rand() % 255; setPixelColor(x,y,r,g,b); } } I'd like to do more than just make blue noise, but I'm not sure where to start (Google isn't helping me much today), so it would be great if you could share anything you know on the subject or some links to related resources.

    Read the article

  • Vim Editor is very smart?

    - by Narek
    I am programming in C++ or Java. So I want to use Vim editor, because it is very flexible. I have heard that I can configure the Vim editor to be able to go from object to the definition from function to the definition from class name to the definition Do we have any professional Vim-er that could tell me how exactly to configure Vim for that? Thanks in advance. P.S. In case readers will consider this question is not connected with programming, I would say that this is improving speed of programming. So it is a help to the programmer. So please don't close this question. EDIT: Also I would like to know how vim works with code completion and can vim hint the list of methods that are available for the certain object? If yes, then I would like to know how to configure these options too?

    Read the article

  • How to use mmap to point to STL type?

    - by srikfreak
    I have a mmap typecast to a char pointer char *ptr; ptr = (char *)mmap(0, FILESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); This was my earlier code. But now I want to use a map instead of char * as the requirements changed. Now, my map is declared as map i_s_map; How do I change my mmap call to point to the map?

    Read the article

  • mysql_connect() acces denied for system@localhost(using password NO)

    - by user309381
    class MySQLDatabase { public $connection; function _construct() { $this-open_connection(); } public function open_connection() { $this-connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS); if(!$this-connection) { die("Database Connection Failed" . mysql_error()); } else { $db_select = mysql_select_db(DB_NAME,$this-connection); if(!$db_select) { die("Database Selection Failed" . mysql_error()); } } } function mysql_prep($value) { if (get_magic_quotes_gpc()) { $value = stripslashes($value); } // Quote if not a number if (!is_numeric($value)) { $value = "'" . mysql_real_escape_string($value) . "'"; } return $value; } public function close_connection() { if(isset($this->connection)) { mysql_close($this->connection); unset($this->connection); } } public function query(/*$sql*/) { $sql = "SELECT*FROM users where id = 1"; $result = mysql_query($sql); $this->confirm_query($result); //return $result; while( $found_user = mysql_fetch_assoc($result)) { echo $found_user ['username']; } } private function confirm_query($result) { if(!$result) { die("The Query has problem" . mysql_error()); } } } $database = new MySQLDatabase(); $database-open_connection(); $database-query(); $database-close_connection(); ?

    Read the article

  • Exception cause in Java ME

    - by Casebash
    In Java SE it is possible set the cause of an exception using initCause to avoid losing information about the error when catching and rethrowing an exception Is it possible to do the same in Java ME?

    Read the article

  • What are the best options for a root filesystem hosted on SSD under Linux

    - by stsquad
    I'm working on an embedded system which is going to be booting and hosting it's rootfs on an SSD disk. We are currently looking at using Intel X-18M SSDs. The file system structure will have a fairly static /usr section (modulo software upgrades) and an active /var and /var/log for maintaining state and logging. Given the wear-levelling done by the underlying flash does having separate partitions help or hinder? As modern SSDs appear as straight block devices and hide their mapping magic behind their firmware is there any point trying to optimise the choice of file-system that sits on-top of the SSD? Finally does enable SMART monitoring make any sense in this context or are their SSD specific ways of determining the underlying health of the storage hardware?

    Read the article

  • How to access a method on a generic datacontext which is only created at runtime

    - by Jeremy Holt
    I'm creating my generic DataContext using only the connectionString in the ctor. I have no issues in retrieving the table using DataContext.GetTable(). However, I need to also be able to retrieve entities of inline table functions. The dbml designer generates public IQueryable<testFunctionResult> testFunction() { return this.CreateMethodCallQuery<testFunctionResult>(this, ((MethodInfo)(MethodInfo.GetCurrentMethod()))); } The question is how do I get the MethodInfo.GetCurrentMethod() when the DataContext has no method called "testFunction", i.e.typeof(DataContext).GetMethod("testFunction") returns null? What I'm trying to achieve is something like: public class UnitofWork<T> { public UnitofWork(string connectionString) { this.DataContext = new DataContext(connectionString); } public UnitofWork(IQueryable<T> tableEntity) { _tableEntity = tableEntity; } public IQueryable<T> TableEntity { get { if (DataContext == null) return _tableEntity; var metaType = DataContext.Mapping.GetMetaType(typeof (T)); if (metaType.IsEntity) _tableEntity = DataContext.GetTable<T>(); else { var s = typeof(T).Name; string methodName = s.Substring(0, s.IndexOf("Result")) + "()"; // the designer automatically affixes "Result" to the type name // Make a method from methodName // _tableEntity = DataContext.CreateMethodCallQuery(DataContext, method, new object[]{}); } return _tableEntity; } set { _tableEntity = value; } } ) Thanks in advance for any insight Jeremy

    Read the article

  • Windows 7 libraries nightmare

    - by Lobuno
    In our active directory we deploy a policy to our clients where the personal directory (My documents) is redirected to a file server of ours \server\share\username\Documents In older systems everything worked fine. in Windows 7 some users are experimenting the following symptoms: The Documents library is EMPTY Where the documents library should be shown in Explorer an empty white icon is displayed. No caption. Right clicking in the Documents library to edit the folders that are part of the libraries brings the dialog up. However, that dialog is unusable. No folder is present there and clicking Add folder does nothing. Deleting the library and auto-creating it doesn't solve the problem The shared directory can be accessed via UNC paths and it can be mounted as a shared drive as well. The library is still broken. The shared drives are on a W2008 indexed server... Using the Windows Library tool utility doesn't solve the problem. What can the cause of this problem be and how can this be solved?

    Read the article

  • Can I create directories that don't exist while creating a new file in emacs?

    - by Jim
    In emacs, I create a file by visiting it with C-x C-f. Let's say I'd like to create /home/myself/new_directory/file.txt. If new_directory does not exist yet, is there a way to have it get created during the creation of file.txt without any extra steps? (I'm thinking of something like using the -p flag to mkdir in Linux.) I feel like there's a different keystroke instead of C-x C-f that can do this, but I can't remember what it is.

    Read the article

  • Ruler to measure in browser (firefox)

    - by danke
    I'm looking for a good ruler to use to measure distances in a browser. I use Firefox. Any good suggestions that are currently being used by other developers. I have firebug, but I don't think it has a ruler. Does it? I would think a ruler would have made it to firebug, but there doesn't seem to be one, or I'm not looking in the right location. Thanks

    Read the article

  • Zip only public directory

    - by Nino55
    Hi guys, I've a lot of websites (100+ directories) I want to create a unique zip with only public subdirectory. My structure now is like: - Site 1 --- app --- tmp --- log --- public - Site 2 --- app --- tmp --- log --- public - ... 100+ dirs ... Now I need a unique zip and then after unzip it I want to see this structure: - Site 1 --- public - Site 2 --- public - others Any suggestion how I can do that with linux commands zip/tar ? Thanks so much!

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >