php-general Digest 17 Oct 2010 05:01:21 -0000 Issue 6991 Topics (messages 308747 through 308756):
Re: odd while behavior...
308747 by: Simon J Welsh
308748 by: Alexander Schrijver
308749 by: [email protected]
Re: Error message not understood
308750 by: sueandant
308751 by: Tommy Pham
308752 by: sueandant
308753 by: Tommy Pham
Binary data unpacking
308754 by: Justin Martin
Addendum: Binary data unpacking
308755 by: Justin Martin
Questions from a Newbie
308756 by: Ethan Rosenberg
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---This is because of your mktime() call. You're trying to get the zeroth day of the month, which is the last day of the preceding month. Using mktime(0, 0, 0, $i, 1) instead should give you the desired results, assuming you do start at 1, and not 0 as you have in your code. --- Simon Welsh On 17/10/2010, at 4:12, Jason Pruim <[email protected]> wrote: > Okay so I'm just playing around with some stuff trying to learn more and > expand my knowledge and I ran into something I don't understand... Take the > following code: > > <?PHP > > echo "<select>"; > $i ="0"; > while($i <="12") { > > $dateformat = date("M", mktime(0,0,0, $i,0,0)); > $month = mktime(0,0,0, $i,0,0); > //echo date("M", mktime(0,0,0, $i,0,0)); > //echo "<br>inside while<br>"; > echo <<<HTML > <option value="{$i}">{$dateformat} {$i}</option> > HTML; > $i++; > } > echo "</select>"; > > ?> > > which does display a select drop down box with the month's in it... But on my > test server it starts the display at december... With setting $i = "1" i > would have thought it should start at january? > > Any ideas on what I missed? :) > > > Thanks for looking! :) > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >
--- End Message ---
--- Begin Message ---On Sat, Oct 16, 2010 at 11:12:03AM -0400, Jason Pruim wrote: > Okay so I'm just playing around with some stuff trying to learn more > and expand my knowledge and I ran into something I don't > understand... Take the following code: > > <?PHP > > echo "<select>"; > $i ="0"; > while($i <="12") { > > $dateformat = date("M", mktime(0,0,0, $i,0,0)); > $month = mktime(0,0,0, $i,0,0); > //echo date("M", mktime(0,0,0, $i,0,0)); > //echo "<br>inside while<br>"; > echo <<<HTML > <option value="{$i}">{$dateformat} {$i}</option> > HTML; > $i++; > } > echo "</select>"; > > ?> > > which does display a select drop down box with the month's in it... > But on my test server it starts the display at december... With > setting $i = "1" i would have thought it should start at january? > > Any ideas on what I missed? :) > > > Thanks for looking! :) > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > You'r specifying day 0. Which actually is in december. It is an optional argument. So you can specifify mktime(0,0,0,$1) instead.
--- End Message ---
--- Begin Message ---I wouldn't really use a while statement for this, but a for loop instead, as it needs less code: <?php echo "<select>"; for($i =1;$i<=12;$i++) { $dateformat = date("M", mktime(0,0,0, $i,0,0)); echo <<<HTML <option value="$i">$dateformat $i</option> HTML; } echo "</select>"; ?> The other code was starting from 0 and going to 12, which is 13 months! Also, you had the variable being compared as a string, which will work in this particular case, because php will convert $i to a string before each comparison in the loop. While it works in this case, its best practice to use the variable type you need to avoid unusual behavior. The mktime function is unusual in that indexes for months start at 1 and not 0 as you might expect, but it does indicate that on the manual pages. Thanks, Ash http://www.ashleysheridan.co.uk ----- Reply message ----- From: "Jason Pruim" <[email protected]> Date: Sat, Oct 16, 2010 16:12 Subject: [PHP] odd while behavior... To: "PHP General list" <[email protected]> Okay so I'm just playing around with some stuff trying to learn more and expand my knowledge and I ran into something I don't understand... Take the following code: <?PHP echo "<select>"; $i ="0"; while($i <="12") { $dateformat = date("M", mktime(0,0,0, $i,0,0)); $month = mktime(0,0,0, $i,0,0); //echo date("M", mktime(0,0,0, $i,0,0)); //echo "<br>inside while<br>"; echo <<<HTML <option value="{$i}">{$dateformat} {$i}</option> HTML; $i++; } echo "</select>"; ?> which does display a select drop down box with the month's in it... But on my test server it starts the display at december... With setting $i = "1" i would have thought it should start at january? Any ideas on what I missed? :) Thanks for looking! :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message --- I've run both programs. [1] outputs Client library version 5.1.51, but [2] gives no output. However I have checked MySql status via the command prompt which tells me mysql Ver 14.14 Distrib 5.1.51 for Win32(ia32).I originally installed PHP 5.3 but I couldn't get it to communicate with mysqli (and I tried everything!) so I unstalled it and replaced it with version 5.2.14. PHP info tells me this that the Client API library version is 5.1.51 and the header version is 5.0.51a.Does this help identify a solution? Thanks and best wishes tholland----- Original Message ----- From: "Luigi Pressello" <[email protected]>To: "Tommy Pham" <[email protected]>Cc: "'sueandant'" <[email protected]>; "'PHP'" <[email protected]>Sent: Friday, October 15, 2010 10:46 PM Subject: Re: [PHP] Error message not understood Probably a PHP compilation problem.The message seems refer to the headers (libmysql.h) used in the ./configure phase of the building process.It seems like your PHP version was compiled using a MySQL 5.0.11 version header, while your connecting to a server running MySQL 5.1.51, Have you upgraded your MySQL recently? are you using the MySQL server on the same machine that runs Apache/IIS/etc.. and PHP?Sorry for the "Italianese" english :) Luigi. Il giorno 15/ott/2010, alle ore 23.19, Tommy Pham ha scritto:-----Original Message----- From: Tommy Pham [mailto:[email protected]] Sent: Friday, October 15, 2010 2:16 PM To: 'sueandant'; 'PHP' Subject: RE: [PHP] Error message not understood-----Original Message----- From: sueandant [mailto:[email protected]] Sent: Friday, October 15, 2010 2:02 PM To: PHP Subject: [PHP] Error message not understood Can anyone help me with this error message and explain how to correct the mismatch? PHP Warning: mysqli_connect() [<a href='function.mysqli- connect'>function.mysqli-connect</a>]: Headers and client library minor version mismatch. Headers:50051 Library:50151 thollandIt would help if you provide the platform and platform version: Windows, Linux, Mac, FreeBSD, or other variants. And also the PHP version you're using. Did you compile PHP yourself orusea distribution? Regards, TommyForgot to mention this earlier... too hasty on the send button ... lol.Since it's only a warning and you are able to connect, run [1] & [2] to seewhat do you get. [1] http://us2.php.net/manual/en/mysqli.get-client-info.php [2] http://us2.php.net/manual/en/mysqli.info.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---> -----Original Message----- > From: sueandant [mailto:[email protected]] > Sent: Saturday, October 16, 2010 1:16 PM > To: Luigi Pressello > Cc: PHP > Subject: Re: [PHP] Error message not understood > > I've run both programs. [1] outputs Client library version 5.1.51, but [2] > gives no output. However I have checked MySql status via the command > prompt which tells me mysql Ver 14.14 Distrib 5.1.51 for Win32(ia32). You still haven't answer the question of what platform? FreeBSD? Linux? Mac? Windows? And what is the platform version? > > I originally installed PHP 5.3 but I couldn't get it to communicate with mysqli > (and I tried everything!) so I unstalled it and replaced it with How did you uninstall? Using the OS's software/package manager such package on FreeBSD, yast on some Linux, add/remove programs on Windows, etc.? Did you compile any of it - MySQL or PHP - yourself? > version 5.2.14. PHP info tells me this that the Client API library version > is 5.1.51 and the header version is 5.0.51a. This just means that there's a mismatch within the PHP. If you compiled from source for any of it, PHP's MySQL & MySQLi extensions depends on the MySQL headers and client library. Thus, MySQL client has to be compiled first before you can compile the PHP's MySQL/MySQLi extensions. This applies to all platforms if you're doing your compilation from source. If you didn't compile any of it - both MySQL and PHP - then the problem lies within your OS's software/package manager. Without knowing what you're using, we can't really tell what happens. Some Linux distributions do things differently. I'm not well versed in Linux but many others here on this list can help you with it. I suggest you 'uninstall' both PHP & MySQL. Then reinstall MySQL 1st and PHP 2nd. Also, just a bit curious... where did you get the MySQL & PHP? I hope directly from the official source... ;) > > Does this help identify a solution? > > Thanks and best wishes > > tholland <snip> Regards, Tommy
--- End Message ---
--- Begin Message --- Apologies! Vista Home Premium 32bit with SP2. I uninstalled it using Windows' uninstaller. I didn't compile any of the packages. MySQL was installed using the .msi download and PHP I simply unzipped to my C:\PHP folder. And, yes, they both came from the official sites.----- Original Message ----- From: "Tommy Pham" <[email protected]> To: "'sueandant'" <[email protected]>; "'Luigi Pressello'" <[email protected]>Cc: "'PHP'" <[email protected]> Sent: Saturday, October 16, 2010 9:38 PM Subject: RE: [PHP] Error message not understood-----Original Message----- From: sueandant [mailto:[email protected]] Sent: Saturday, October 16, 2010 1:16 PM To: Luigi Pressello Cc: PHP Subject: Re: [PHP] Error message not understoodI've run both programs. [1] outputs Client library version 5.1.51, but [2]gives no output. However I have checked MySql status via the command prompt which tells me mysql Ver 14.14 Distrib 5.1.51 for Win32(ia32).You still haven't answer the question of what platform? FreeBSD? Linux? Mac?Windows? And what is the platform version?I originally installed PHP 5.3 but I couldn't get it to communicate withmysqli(and I tried everything!) so I unstalled it and replaced it withHow did you uninstall? Using the OS's software/package manager such packageon FreeBSD, yast on some Linux, add/remove programs on Windows, etc.? Did you compile any of it - MySQL or PHP - yourself?version 5.2.14. PHP info tells me this that the Client API libraryversionis 5.1.51 and the header version is 5.0.51a.This just means that there's a mismatch within the PHP. If you compiled from source for any of it, PHP's MySQL & MySQLi extensions depends on the MySQL headers and client library. Thus, MySQL client has to be compiled first before you can compile the PHP's MySQL/MySQLi extensions. This applies to all platforms if you're doing your compilation from source. If you didn't compile any of it - both MySQL and PHP - then the problem lies within your OS's software/package manager. Without knowing what you're using, we can't really tell what happens. Some Linux distributions do things differently. I'm not well versed in Linux but many others here onthis list can help you with it. I suggest you 'uninstall' both PHP & MySQL. Then reinstall MySQL 1st and PHP 2nd. Also, just a bit curious... where didyou get the MySQL & PHP? I hope directly from the official source... ;)Does this help identify a solution? Thanks and best wishes tholland<snip> Regards, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---> -----Original Message----- > From: sueandant [mailto:[email protected]] > Sent: Saturday, October 16, 2010 2:23 PM > To: Tommy Pham > Cc: PHP > Subject: Re: [PHP] Error message not understood > > Apologies! Vista Home Premium 32bit with SP2. I uninstalled it using > Windows' uninstaller. I didn't compile any of the packages. MySQL was > installed using the .msi download and PHP I simply unzipped to my C:\PHP > folder. And, yes, they both came from the official sites. > Forgot to mention something, please don't top post. It makes hard for others to follow the thread. Are you running PHP with IIS or Apache? If with Apache how are you running PHP as, CGI or module? Since you're using official distributions, you'll have to use PHP VC6 TS build (if not using as CGI/FastCGI) for Apache [1]. If you're running PHP with IIS, you'll have to run NTS build for FastCGI [2]. [1] http://windows.php.net/downloads/releases/php-5.3.3-Win32-VC6-x86.zip [2] http://windows.php.net/downloads/releases/php-5.3.3-nts-Win32-VC9-x86.zip > ----- Original Message ----- > From: "Tommy Pham" <[email protected]> > To: "'sueandant'" <[email protected]>; "'Luigi Pressello'" > <[email protected]> > Cc: "'PHP'" <[email protected]> > Sent: Saturday, October 16, 2010 9:38 PM > Subject: RE: [PHP] Error message not understood > > > >> -----Original Message----- > >> From: sueandant [mailto:[email protected]] > >> Sent: Saturday, October 16, 2010 1:16 PM > >> To: Luigi Pressello > >> Cc: PHP > >> Subject: Re: [PHP] Error message not understood > >> > >> I've run both programs. [1] outputs Client library version 5.1.51, but > >> [2] > >> gives no output. However I have checked MySql status via the command > >> prompt which tells me mysql Ver 14.14 Distrib 5.1.51 for Win32(ia32). > > > > You still haven't answer the question of what platform? FreeBSD? Linux? > > Mac? > > Windows? And what is the platform version? > > > >> > >> I originally installed PHP 5.3 but I couldn't get it to communicate with > > mysqli > >> (and I tried everything!) so I unstalled it and replaced it with > > > > How did you uninstall? Using the OS's software/package manager such > > package > > on FreeBSD, yast on some Linux, add/remove programs on Windows, etc.? > Did > > you compile any of it - MySQL or PHP - yourself? > > > >> version 5.2.14. PHP info tells me this that the Client API library > > version > >> is 5.1.51 and the header version is 5.0.51a. > > > > This just means that there's a mismatch within the PHP. If you compiled > > from source for any of it, PHP's MySQL & MySQLi extensions depends on > the > > MySQL headers and client library. Thus, MySQL client has to be compiled > > first before you can compile the PHP's MySQL/MySQLi extensions. This > > applies to all platforms if you're doing your compilation from source. If > > you didn't compile any of it - both MySQL and PHP - then the problem lies > > within your OS's software/package manager. Without knowing what > you're > > using, we can't really tell what happens. Some Linux distributions do > > things differently. I'm not well versed in Linux but many others here on > > this list can help you with it. I suggest you 'uninstall' both PHP & > > MySQL. > > Then reinstall MySQL 1st and PHP 2nd. Also, just a bit curious... where > > did > > you get the MySQL & PHP? I hope directly from the official source... ;) > > > >> > >> Does this help identify a solution? > >> > >> Thanks and best wishes > >> > >> tholland > > > > <snip> > > > > Regards, > > Tommy > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > >
--- End Message ---
--- Begin Message ---Hello everyone,For the past while, I've been working on a class for reading in, modifying and writing out NBT-format files. This particular format is used for the game Minecraft, as some of you may know.Attached is my work so far on this, which is coming close to being a working solution to reading the files in. As well, attached is an example NBT for testing the script.The specification for the NBT format can be found at http://www.minecraft.net/docs/NBT.txt.The issue which I'm having is that PHP's pack and unpack function for binary data does not seem to be complete. Or, at least, it's missing certain functionality which is necessary for what I'm trying to do.It may be a matter of misunderstanding on my part, but I would have expected the pack and unpack function to be able to handle every combination of endianness, signing and machine-specific sizing of each type.Currently, I'm stuck in reading in the TAG_INT type of the NBT format, which is a 32-bit signed short, big-endian, as per the specification. There does not seem to be a packing format code for this data type.How might I go about this? Am I simply missing something about binary data, or is PHP's pack/unpack functionality indeed lacking? And, if the pack and unpack functions are indeed lacking, is it possible to handle binary data without those functions?Thanks, Justin Martin<<attachment: nbt.class.php>>
--- End Message ---
--- Begin Message ---Sorry, I had forgotten that attachments weren't accepted on the list. My code can be found at http://pastebin.com/6nmR67c3. The test NBT can be found via the NBT specification link. Thanks, Justin Martin
--- End Message ---
--- Begin Message ---Dear List -Here are some questions, which I am sure are trivial, but I am a newbie, and cannot find the answers online....I cannot get the following to work. In my Firefox [Iceweasel] browser, I enter the following URL: [w/ the http]localhost/CreateNew.php All I get is a blank browser screen. The code contained in the file CreateNew.php is: /* * Create Database test22 */ <html><body> <?php $cxn = mysqli_connect("$host",$user,$password); echo "Create database test22;" echo "Create table Names2 ( RecordNum Int(11) Primary Key Not null default=10000 auto_increment, FirstName varchar(10), LastName varchar(10), Height decimal(4,1), Weight0 decimal(4,1), BMI decimal(3,1) Date0 date );" echo" Create table Visit2 ( Indx Int(7) Primary Key Not null auto_increment, Weight decimal(4,1) not null, StudyDate date not null, RecordNum Int(11) );" $sql= "SHOW DATABASES"; ?> </body></html> If I search for test22 or Visit2, nothing is found.I would also like to be able to add data to a table, using PHP, which I can do in MySQL as: load data infile '/home/ethan/Databases/tester21.dat.' replace into table Names fields escaped by '\\' terminated by '\t' lines terminated by '\n' ;Thanks in advance. Ethan =======Using Debian(sid)
--- End Message ---
