Jump to content

woodworks

New Members
  • Posts

    6
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

woodworks's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Turns out the bug has nothing to do with 32-bit vs 64-bit. It's a bug that was addressed in PHP 5.3. The system I am running it on is an old Ubuntu 8.04 server which has PHP 5.2 installed. Also, the bug is just a formatting issue caused by the conversion from float to string. Using printf to format the output instead of a simple echo will force PHP 5.2 to display the correct value.
  2. Thanks for the responses. It must be something with older software/OS. The problem is occurring on an Ubuntu 8.0.4.4 LTS, 64-bit, server install. The problem does not occur on an Ubuntu 10.04.3 LTS, 64-bit, server installation.
  3. Trying to write a decimal to base-32 converter and ran into a strange problem. If I run this code: <?php $result = 657911351231 / 32; echo $result; ?> On a 32-bit machine the output is: 20559729725.969 On a 64-bit machine the output is: 20559729726 What gives? Why is the 32-bit system producing a more accurate result? How do I force PHP to return the more accurate result on the 64-bit machine? Thanks.
  4. That depends COMPLETELY on the context in which you want to display the results. Personally I suggest creating a static HTML page with "test" data and then creating your PHP to match. In some cases I would just hard-code the functioality to write the data to the page. In other's (such as a report listing) I might create a function or class to display the data tomaintain consistency. Those are used in instances where you run multiple queries at once. I never do that myself. I would suggest sticking with running queries individually - at least initially. Because debugging will be more complicated otherwise. Once you are more familiar with PHP/MySQL, then you can venture into the more complicated. The examples int he manual seem to provide a pretty good explanation in my opinion. As for books, I would suggest looking for some good online tutorials. A google search for "PHP MySQL Tutoria" brings up some good results. If anything doesn'ty make sense to you then you can post on these forums. Thank you for the response. I've found several tutorials online covering all sorts of different examples. The problem I am having is finding information that provides the rationale behind the code. I don't want to be a code monkey that simply regurgitates some else's code. I want to understand what the code is doing and the reasoning behind it (e.g., performance, fewer lines of code, security issues) so that I can make good choices when writing my own. The tutorials and forum posts on this site have been some of the most informative yet. I can't believe my Google searches the past few weeks have not listed this site before. I had to go down several pages in my latest search to even find the one which took me here. Let's hope the O'Reilly online MySQL and PHP courses that I am going to take are just as good. Who knows, maybe someday I'll be able to provide assistance to users of this forum, too.
  5. Great tip. Thanks. Can you also recommend a good book for learning to use PHP with MySQL? TC
  6. I'm learning PHP and ran into something I can't quite figure out if what I am doing is really the way I should or if there is a better way. Here's an example. If I use this code to get information and display the results: $time = mysqli_query($link, "SELECT UNIX_TIMESTAMP()"); print $time; My browser returns Object id #3 (I'm running PHP through Apache2). But, if I use this code: $time = mysqli_query($link, "SELECT UNIX_TIMESTAMP()"); while ($row = mysqli_fetch_array($time)) { print $row[0]; } I get the actual result of (i.e., the content of the object held by $time) the SELECT statement to print to the browser which is what I want. I understand from the online PHP manual (see http://us3.php.net/mysqli_query) that mysqli_result will return a result object (hence the reason for the "Object id #3" message?), but then it goes on to say the "resultmode" is mysqli_use_result or mysqli_store_result. I read about these in the online PHP manual and am confused. I've been reading the SAMS Teach Yourself "PHP, MySQL, and Apache" book and cannot find any detailed explanation as to: 1. What is the best way to print the results of a mysqli_query to a browser (I seriously doubt the above method I am currently using is the best). I have no problem understanding why using my above method might be appropriate when I have multiple rows of data being returned, but to do this when I know that only a single row, with one item, will be returned seems odd. 2. How do you use MYSQLI_USE_RESULT and MYSQLI_STORE_RESULT? Every Google search I do pretty much points me to a copy of what the online PHP manual says with no further explanation. Also, could somebody please recommend a more comprehensive book than the SAMS book I am reading? Thanks. TC
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.