php-windows Digest 22 Aug 2003 02:28:29 -0000 Issue 1881
Topics (messages 21199 through 21209):
Call for Authors 2
21199 by: WebDevMagazine
Store array in mysql?
21200 by: Disko_kex
21203 by: Rob Adams
21205 by: Sek-Mun Wong
Form data
21201 by: Muhammad Imran
21202 by: John Ellingsworth
Re: how to establish relationship in Mysql
21204 by: Rob Adams
21206 by: Ignatius Reilly
21207 by: Rob Adams
COM - ADODB connection...
21208 by: Chris Kranz
Re: ascii to utf-16
21209 by: Joel Rees
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 ---
WebDevMagazine will start in September an international edition of
magazine.If you want to be an author of this magazine please email to :
[EMAIL PROTECTED] the folowing things:
1. Your details - name , age ,...etc
2. Your experience
3. In what topic from Web Development you want to write articles(news,
reviews)
URL: http://webdevmagazine.co.uk/n/
----------------------------
Author Guide-lines
----------------------------
WebDevMagazine is a free of charge magazine for web development and
technologies. We working over topics like : Internet programming, web
design, software architecture, etc.
1. What should be your material?
- At least one page(html, doc or text) in which should be included graphics
or schemes if it necessary.
- Without company or software presentations.
- Should cover the topics of the magazine and could be: an article, a piece
of news or interview.
(the people that we have inteviewed for our previous issues , for example
are: Andrei Zmievski (PHP group),Chris Peacock(FORTUNE magazine), Andy
Williams(Yahoo! UK&Ireland).etc. )
2. What kind of information we need about you?
- sample presentation of you
- picture if available
- contact details (e-mail, messenger, country, etc.)
3. What is your advantage?
-WebDevMagazine is a free of charge magazine and we are not able to pay
you, but you can work for a great magazine, developed from great people
including you.
-All rights of your material depends on you.
If you have questions please fell free to contact WebDevMagazine anytime.
[EMAIL PROTECTED]
Best Regards
Bogomil Shopov
--------------
Please if you are agree with this document, fill the following data:
-------------------------------------------------------------------
Name ................
Email .................
I agree with this document.
--------------------------------------------------------------------
--- End Message ---
--- Begin Message ---
If I have a normal array like "Array ( [0] => 1 [1] => 3 [2] => 82 )" ,
and want to store the array in a mysql table and then want to use it.
How can I do?
// jocke
--- End Message ---
--- Begin Message ---
"Disko_kex" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> If I have a normal array like "Array ( [0] => 1 [1] => 3 [2] => 82 )" ,
> and want to store the array in a mysql table and then want to use it.
> How can I do?
>
> // jocke
>
There are at least two ways you can do this. If you really want to use a
mysql table (not recommended) and your keys are all sequential integers,
just implode the array and save it in a text or long char field. If you
just need to save the array temporarily between pages, use sessions.
-- Rob
--- End Message ---
--- Begin Message ---
use "serialize".
you need to create a table with 2 fields, key & value, where value is a
largetext field.
$str = serialize($array);
mysql_query("insert into table1 (key, value) as ($key, $str)");
then you can select it back out of mysql and use
$result = mysql_query("select....");
$array = unserialize($result[0]->value);
pardon if the php doesn't work, i'm just typing it off the top of my head
"Disko_kex" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> If I have a normal array like "Array ( [0] => 1 [1] => 3 [2] => 82 )" ,
> and want to store the array in a mysql table and then want to use it.
> How can I do?
>
> // jocke
>
--- End Message ---
--- Begin Message ---
How i can process my form data, my form contain just one text input field and .php
code have to show it but when i press ""SUBMIT" button my page url does not change nor
the input text seen thier. my php code is :
<html>
<body>
<p>Welcome<?php echo ($Applicant); ?>!</p>
</body>
</html>
html form just send the input text with Applicant text field data. However my php and
apache is working fine. Do any one have idea.
Imran
--- End Message ---
--- Begin Message ---
Muhammad
You need to grab the variable first - register_globals is in safe mode,
probably - so you should do this (you seem to be using an older, insecure
method of doing it):
<html>
<body>
<p>Welcome
<?php
if (isset($_POST["Applicant"])) {
$Applicant = $_POST["Applicant"];
} else {
$Applicant = "Nobody";
}
echo ($Applicant);
?>!</p>
</body>
</html>
Thanks,
John Ellingsworth
http://mail.med.upenn.edu/~jellings/
-----Original Message-----
From: Muhammad Imran [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 21, 2003 10:57 PM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] Form data
How i can process my form data, my form contain just one text input field
and .php code have to show it but when i press ""SUBMIT" button my page url
does not change nor the input text seen thier. my php code is :
<html>
<body>
<p>Welcome<?php echo ($Applicant); ?>!</p>
</body>
</html>
html form just send the input text with Applicant text field data. However
my php and apache is working fine. Do any one have idea.
Imran
--- End Message ---
--- Begin Message ---
"Thomas Edward Lawrence" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> May it establish relationship in Mysql as if we can establish relationship
> between tables in Access ? If can , please tell me , I use php Myadmin and
> EMS Mysql manager version 2.5 , thank you .
>
>
If you're looking for foreign keys, no. MySQL doesn't support that.
(Though I think it may be on the list of things to do.)
-- Rob
--- End Message ---
--- Begin Message ---
Not so. Actually you can enforce FOREIGN KEYs if you choose the InnoDB table
type.
Ignatius
_________________________
----- Original Message -----
From: "Rob Adams" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 21, 2003 5:41 PM
Subject: [PHP-WIN] Re: how to establish relationship in Mysql
> "Thomas Edward Lawrence" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > May it establish relationship in Mysql as if we can establish
relationship
> > between tables in Access ? If can , please tell me , I use php Myadmin
and
> > EMS Mysql manager version 2.5 , thank you .
> >
> >
>
> If you're looking for foreign keys, no. MySQL doesn't support that.
> (Though I think it may be on the list of things to do.)
>
> -- Rob
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Wow. That's nice. Never heard of that table type before.
-- Rob
"Ignatius Reilly" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Not so. Actually you can enforce FOREIGN KEYs if you choose the InnoDB
table
> type.
>
> Ignatius
> _________________________
> ----- Original Message -----
> From: "Rob Adams" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, August 21, 2003 5:41 PM
> Subject: [PHP-WIN] Re: how to establish relationship in Mysql
>
>
> > "Thomas Edward Lawrence" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> > > May it establish relationship in Mysql as if we can establish
> relationship
> > > between tables in Access ? If can , please tell me , I use php Myadmin
> and
> > > EMS Mysql manager version 2.5 , thank you .
> > >
> > >
> >
> > If you're looking for foreign keys, no. MySQL doesn't support that.
> > (Though I think it may be on the list of things to do.)
> >
> > -- Rob
> >
> >
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
--- End Message ---
--- Begin Message ---
so i have something like this...
$xlsFile = $_FILES['fileupload']['tmp_name']; //the file we're reading is
the one we just uploaded
$conn= new COM("ADODB.Connection") or die( "did not connect" );
$conn->Open("Driver={Microsoft Excel Driver
(*.xls)};DBQ=$xlsFile;ExtendedProperties=Excel 8.0;");
$SQL = "Select * FROM [Schedule$]"; // then we pull out all the info into
a record set from the sheet we want
$results = $conn->Execute($SQL);
$c=0;
$s = $results->fields->Count(); // count it, and run through the record
set, putting it into an array...
while(!$results->eof){
for( $i=0; $i<$s; $i++ )
{
$sheets[$c][$i] = $results->fields[$i]->value."
[".$results->fields[$i]->type."]";
print $sheets[$c][$i]."-";
}
print "\r\n";
$results->movenext();
$c++;
}
the problem i'm having is that PHP seems to be loosing some information.
this scripts works perfectly in that it gets all the relevant info out of
the excel file. but when it comes to number only cells, or date cells, it
just looses the information. totally looses it. if i check
$results->fields[$i]->type it gives me that they are all type 200 (strings)
but it doesn't seem to be converting them to a string properly?
any help? is there any way i can specify how it converts them? or not to
convert them fully? the manual is very thin on any kind of good description
of the COM objects, and so is the internet. most people don't connect to
excel files this way, but connecting straight to excel just isn't viable,
and is riddled with bugs.
--- End Message ---
--- Begin Message ---
"Achilles Maroulis" <[EMAIL PROTECTED]>
> > Is there a way to convert a string to unicode utf-16?
>
> Apparently not built into php, which sort of surprises me..
>
> You could make one if you want, it's not hard.
> ...
> If you REALLY REALLY REALLY want a conversion function, I might be able
> to build one for you next week. But I don't think you want one. Try this
> instead:
>
> header( 'Content-Type: text/html; charset=UTF-8' );
Okay, I got this far two weeks ago, haven't been able to break any more
time out since. (Take the kids to see the dolphins and all, you know.)
So I'm posting what I have, which is incomplete and entirely untested.
It should serve as a starting point for anyone who really wants to be
able to convert between forms.
Note the comment at the end -- there is no way to tell how far the parse
went. The only way to catch an error is to check that the returned value
is not in the range (128 .. 255), which is an entirely unacceptable
method of checking errors. Using reference parameters to return the
moved buffer pointer and an error flag would be trivial, so that would
be the next step after reading through the code and before testing.
And, of course, if you need utf-8 to utf-16, you'll need another routine
to fold values out of the basic plane to surrogate pairs, which process
is also described somewhere on unicode.org's pages.
-------------------------------------------------------------------
/* Parses one Unicode character out of a nominally utf-8 stream
// and returns the utf-32 (i. e., 32 bit integer) encoding.
// On error, returns the next byte from the stream.
// Joel Rees, Amagasaki, Japan, July 2003, released to public domain.
// Full of bugs! Fix before using! Use at your own risk!
// (Neither I nor the company I work for assume any responsibility for this code.)
*/
function parseOneUTF8( $buffer, $position )
{ $point = 0;
#count = 0;
$error = 0;
$buflen = length( $buffer );
if ( position < $buflen )
{ $lead = ord( substr( $buffer, $position++, 1 ) );
if ( $lead < 0x80 )
{ $count = 1;
$point = $lead;
}
elseif ( $lead >= 0xC0 && $lead <= 0xDF )
{ $count = 2;
$point = ( $lead & 0x1F );
}
elseif ( $lead >= 0xE0 && $lead <= 0xEF )
{ $count = 3;
$point = ( $lead & 0x0F );
}
elseif ( $lead >= 0xF0 && $lead <= 0xF7 )
{ $count = 4;
$point = ( $lead & 0x07 );
}
else
{ $error = 1;
}
/* 0xF8 ~ 0xFF not lead octets in Unicode UTF-8. */
for ( $i = 0; $i < $count - 1; ++i )
{
if ( $position < $buflen )
{ $next = ord( substr( $buffer, $position++, 1 ) );
if ( $next >= 0x80 && $next <= 0xBF )
{ $point <<= 6;
&point |= ( $next & 0x3F );
}
else
{ $error = 1;
}
}
else
{ $error = 1;
}
}
switch ( $count )
{
case 2:
if ( $point < 0x80 )
{ $error = 1;
}
break;
case 3:
if ( $point < 0x800 )
{ $error = 1;
}
break;
case 4:
if ( $point < 0x10000 )
{ $error = 1;
}
break;
}
}
if ( $point >= 0xd800 && $point <= 0xdfff )
{ $error = 1;
}
if ( $error != 0 && $count > 1 )
{ $count = 1;
$point = $lead;
}
/* Also need to return $count or the parse point,
// and $error, of course, through reference parameters.
*/
return $point;
}
-------------------------------------------------------------------
--
Joel Rees, programmer, Systems Group
Altech Corporation (Alpsgiken), Osaka, Japan
http://www.alpsgiken.co.jp
--- End Message ---