[PHP] mysqli fetch-fields returns blob for text

2011-01-04 Thread Mari Masuda
Hello,

On http://www.php.net/manual/en/mysqli.constants.php there are some predefined 
constants for MYSQLI_TYPE_TINY_BLOB, MYSQLI_TYPE_MEDIUM_BLOB, 
MYSQLI_TYPE_LONG_BLOB, and MYSQLI_TYPE_BLOB.  Through some experimentation I 
have found that fields in my MySQL database that are declared as 'text' in 
MySQL are categorized by PHP as 'blob' when I compare the above constants to 
the field's type using 
http://www.php.net/manual/en/mysqli-result.fetch-fields.php.

In the MySQL documentation http://dev.mysql.com/doc/refman/5.1/en/blob.html in 
the second paragraph it states: 
---
BLOB values are treated as binary strings (byte strings). They have no 
character set, and sorting and comparison are based on the numeric values of 
the bytes in column values. TEXT values are treated as nonbinary strings 
(character strings). They have a character set, and values are sorted and 
compared based on the collation of the character set.
---

I was wondering if PHP's interpretation of 'text' as 'blob' could cause me any 
trouble down the road and what the workarounds are, if any.  Thank you.

Mari
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] a loop constructing the URLs and make PHP to fetch up to 100 pages [ a seven liner]

2010-10-30 Thread jobst müller
dear list - good Morning!


i want to parse the site - and get the results out of it:

http://www.educa.ch/dyn/79363.asp?action=search

therefore i need to loop over the line 2 - don ´ i!?


 ?php
 $data = file_get_contents('http://www.educa.ch/dyn/79363.asp?action=search');
 $regex = '/Page 1 of (.+?) results/';
 preg_match($regex,$data,$match);
 var_dump($match);
 echo $match[1];
 ?


in order to get the details of the pages - 

http://www.educa.ch/dyn/79376.asp?id=4438
http://www.educa.ch/dyn/79376.asp?id=53

and so forth - well i need a foreach statement in line two - don´ t i!? 


just help me with this seven-liner  ;)

on a sidenote: measuring code in terms of how many lines it took to write is 
a Perl-coder-attitude. Only Perl programmers care about that and i find it hard 
it is to read Perl code.

love to hear from you
___
GRATIS! Movie-FLAT mit über 300 Videos. 
Jetzt freischalten unter http://movieflat.web.de

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Newibie: fetch Obj question - data not showing.

2009-04-05 Thread MEM
Hello,

1) 
Ok, with mysqli, to fetch data from a database to a select drop down list, we 
would do something like this right? :
?php 
$result = $mysqli-query(SELECT id_cliente, nome_cliente FROM cliente);
echo select id='listacliente' name='listacliente'; 

while($row = mysqli_fetch_assoc($result)) { 
echo option value=.$row['id_cliente']..$row['nome_cliente']./option;
}

echo /select;
?

2)
What I’m trying to achieve? 
The same thing, but using PDO, the prepare/execute methods, and FETCH_OBJ 
method to fetch data. 

3)
Here is what I have done so far:
For simplifying I’m just trying to echo:

$queryh=$conn-prepare('SELECT id_cliente, nome_cliente FROM cliente');
$queryh-execute();

/*trys to access the method fetchObject of the PDOStatement generated by the 
execute() PDO method, and save it on $row variable:*/
$row=$queryh-fetchObject(); 

/*now I'm trying to echo the results. The 'id_cliente' and 'nome_cliente' are 
the column names of my database and, if I get it right, the fectchObject() 
method should allow me to access those names as anonymous properties. So: */
echo Id: .$row-id_cliente. - Nome: .$row-nome_cliente./ br;


4)
Here is the issue that I’m getting:
I’m getting no values from the database upon echo request. 


5) 
Question:
What is wrong with this code? :(


Regards,
Márcio


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Newibie: fetch Obj question - data not showing.

2009-04-05 Thread 9el
On Sun, Apr 5, 2009 at 10:08 PM, MEM tal...@gmail.com wrote:

 Hello,

 1)
 Ok, with mysqli, to fetch data from a database to a select drop down list,
 we would do something like this right? :
 ?php
 $result = $mysqli-query(SELECT id_cliente, nome_cliente FROM cliente);
 echo select id='listacliente' name='listacliente';

 while($row = mysqli_fetch_assoc($result)) {
 echo option
 value=.$row['id_cliente']..$row['nome_cliente']./option;
 }

 echo /select;
 ?

 2)
 What I’m trying to achieve?
 The same thing, but using PDO, the prepare/execute methods, and FETCH_OBJ
 method to fetch data.

 3)
 Here is what I have done so far:
 For simplifying I’m just trying to echo:

 $queryh=$conn-prepare('SELECT id_cliente, nome_cliente FROM cliente');
 $queryh-execute();

 /*trys to access the method fetchObject of the PDOStatement generated by
 the execute() PDO method, and save it on $row variable:*/
 $row=$queryh-fetchObject();

 /*now I'm trying to echo the results. The 'id_cliente' and 'nome_cliente'
 are the column names of my database and, if I get it right, the
 fectchObject() method should allow me to access those names as anonymous
 properties. So: */
 echo Id: .$row-id_cliente. - Nome: .$row-nome_cliente./ br;


 4)
 Here is the issue that I’m getting:
 I’m getting no values from the database upon echo request.


 5)
 Question:
 What is wrong with this code? :(


There is something definitely wrong with your code. But why did you forget
to use the debugging functions :

print_r()
and var_dump()  for the results?

So, you'll get some idea beforehand of posting the problem here. I am
looking at the code in a hurry so I cant help you much right away.

Lenin

www.twitter.com/nine_L


RE: [PHP] Newibie: fetch Obj question - data not showing.

2009-04-05 Thread MEM
why did you forget to use the debugging functions :

print_r()
and var_dump()  for the results?

So, you'll get some idea beforehand of posting the problem here. I am
looking at the code in a hurry so I cant help you much right away.

Lenin

 http://www.twitter.com/nine_L www.twitter.com/nine_L

 

 

 

 

Because I've never debug on my entire life of programming (2 months). :D

In the meanwhile, I will search how to debug using print_r  and var_dump.

 

Thanks.



Re: [PHP] Newibie: fetch Obj question - data not showing.

2009-04-05 Thread 9el

 Because I’ve never debug on my entire life of programming (2 months). :D

 In the meanwhile, I will search how to debug using print_r  and var_dump.

 ROFL  ha hahaha

echo 'pre', print_r($array),'/pre';   // here pre is used to
keep the way its outputed in HTML
echo 'pre', var_dump($array),'/pre';

please dont forget to study the online php manual and also the
php_manual.chm version downloaded to your PC.

Its never a good idea to not to debug.


RE: [PHP] Newibie: fetch Obj question - data not showing.

2009-04-05 Thread MEM
On Behalf Of 9el


 

On Sun, Apr 5, 2009 at 10:08 PM, MEM  mailto:tal...@gmail.com
tal...@gmail.com wrote:

Hello,

1)
Ok, with mysqli, to fetch data from a database to a select drop down list,
we would do something like this right? :
?php
$result = $mysqli-query(SELECT id_cliente, nome_cliente FROM cliente);
echo select id='listacliente' name='listacliente';

while($row = mysqli_fetch_assoc($result)) {
echo option
value=.$row['id_cliente']..$row['nome_cliente']./option;
}

echo /select;
?

2)
What I’m trying to achieve?
The same thing, but using PDO, the prepare/execute methods, and FETCH_OBJ
method to fetch data.

3)
Here is what I have done so far:
For simplifying I’m just trying to echo:



$queryh=$conn-prepare('SELECT id_cliente, nome_cliente FROM cliente');
$queryh-execute();

/*trys to access the method fetchObject of the PDOStatement generated by
the execute() PDO method, and save it on $row variable:*/
$row=$queryh-fetchObject();

/*now I'm trying to echo the results. The 'id_cliente' and 'nome_cliente'
are the column names of my database and, if I get it right, the
fectchObject() method should allow me to access those names as anonymous
properties. So: */
echo Id: .$row-id_cliente. - Nome: .$row-nome_cliente./ br;


4)
Here is the issue that I’m getting:
I’m getting no values from the database upon echo request.


5)
Question:
What is wrong with this code? :(

 
There is something definitely wrong with your code. But why did you forget
to use the debugging functions :

print_r()
and var_dump()  for the results?

So, you'll get some idea beforehand of posting the problem here. I am
looking at the code in a hurry so I cant help you much right away.

Lenin

www.twitter.com/nine_L

 

 

 

Despite the debug I’m still not getting what’s going wrong. ;( Any help
would be greatly appreciated.

 

 

Regards,

Márcio



Re: [PHP] Scrape? (Fetch email)

2007-11-12 Thread tedd

I haven't used GA (probably the only web guy left in the world),
but if it has an email feature like Stut mentioned, Tedd, you could
run it through a piped-to-PHP email-parsing script.


That's the idea.

I can send the email from Google to a specific email address.

Now, how can I get php to fetch the email?

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Scrape? (Fetch email)

2007-11-12 Thread Daniel Brown
On Nov 12, 2007 12:46 PM, tedd [EMAIL PROTECTED] wrote:
  I haven't used GA (probably the only web guy left in the world),
 but if it has an email feature like Stut mentioned, Tedd, you could
 run it through a piped-to-PHP email-parsing script.

 That's the idea.

 I can send the email from Google to a specific email address.

 Now, how can I get php to fetch the email?

 Cheers,

 tedd
 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



It doesn't have to fetch the email.

/etc/localalises (or equivalent) Add:
google-analytics: |/path/to/script.php

Then just have mail from that sent to [EMAIL PROTECTED]


-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

If at first you don't succeed, stick to what you know best so that you
can make enough money to pay someone else to do it for you.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Scrape? (Fetch email)

2007-11-12 Thread tedd

At 12:53 PM -0500 11/12/07, Daniel Brown wrote:

On Nov 12, 2007 12:46 PM, tedd [EMAIL PROTECTED] wrote:

  I haven't used GA (probably the only web guy left in the world),
 but if it has an email feature like Stut mentioned, Tedd, you could
 run it through a piped-to-PHP email-parsing script.

 That's the idea.

 I can send the email from Google to a specific email address.

 Now, how can I get php to fetch the email?

 Cheers,

 tedd

  --

It doesn't have to fetch the email.

/etc/localalises (or equivalent) Add:
google-analytics: |/path/to/script.php

Then just have mail from that sent to [EMAIL PROTECTED]


H interesting. Do you mean that I can have an email sent directly 
to a script?


If so, what triggers the script?

How does the script capture the email to parse? Do you have an 
example or reference?


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Scrape? (Fetch email)

2007-11-12 Thread Jake




At 12:53 PM -0500 11/12/07, Daniel Brown wrote:

On Nov 12, 2007 12:46 PM, tedd [EMAIL PROTECTED] wrote:

  I haven't used GA (probably the only web guy left in the world),
 but if it has an email feature like Stut mentioned, Tedd, you could
 run it through a piped-to-PHP email-parsing script.

 That's the idea.

 I can send the email from Google to a specific email address.

 Now, how can I get php to fetch the email?

 Cheers,

 tedd

  --

It doesn't have to fetch the email.

/etc/localalises (or equivalent) Add:
google-analytics: |/path/to/script.php

Then just have mail from that sent to 
[EMAIL PROTECTED]


H interesting. Do you mean that I can have an email sent directly to a 
script?


If so, what triggers the script?

How does the script capture the email to parse? Do you have an example or 
reference?


Cheers,

tedd




I made one using procmail instead of aliases, but same idea... here is a 
snippet


Jake






$buffer = '';
$fp = fopen(php://stdin, r);
if ($fp)
{
 while(!feof($fp))
 {
   $buffer .= fgets($fp, 4096);
 }
 fclose($fp);
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] odbc fetch array issues

2004-11-16 Thread Adil
Hey people,

Anyone know much about odbc_fetch_array() or odbc_fetch_object() functions
in php.  My while loop keeps breaking while using this function.  I'm trying
to grab a row from the result returned by the database query and for testing
purposes, just printing out each item in the row as follows:

$sql = SELECT * FROM users WHERE username='$username' AND
password='$password';
 $result = odbc_exec($dbConnection, $sql);

while ($rows = odbc_fetch_array($result)) {   //This doesn't work with
odbc_fetch_object either
 print $rows-COLUMNNAME;
  }


I get nothing at all which I find pretty strange so I wanted to know if
there were any bugs with this function, maye while working on IIS or just
problems with the functions themselves.

Thx again
Adil.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] odbc fetch array issues

2004-11-16 Thread Jay Blanchard
[snip]
$sql = SELECT * FROM users WHERE username='$username' AND
password='$password';
 $result = odbc_exec($dbConnection, $sql);

while ($rows = odbc_fetch_array($result)) {   //This doesn't work with
odbc_fetch_object either
 print $rows-COLUMNNAME;
  }
[/snip]

For odbc_fetch_array you would have to use

print $rows['COLUMNNAME'];

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Web Fetch Process

2004-09-06 Thread Zoran
Hi

How can I parse HTML page which I fetched by PHP so some part of text would
be replaced by other text.

Also, I managed to delete all HTML code from page (with this code
$data[0] = preg_replace(/([])+([^])+([.])*([])+/i,, $data[0]);

but also would like to delete all chars except numbers from page, can this
be done?

Regards.
Zoran

Your first question:
To replace certain elements take a look at preg_replace()
http://us4.php.net/manual/en/function.preg-replace.php

Example:

$foo = 'stuff bsilly stuff/b more stuff';
echo preg_replace('/\b\(.*)\\/b\/', h1$1 lookie now/h1, $foo);

Your second question:
You could just use strip_tags()
http://us4.php.net/manual/en/function.strip-tags.php

Your last question:
To delete everything but numbers you could $content =
preg_replace('/[^\d]/','', $content);

Hope that helps

Jim Grill

Hi

This works great. One more question about preg_replace. Is it possible that for every 
match other text is replaced?
By this I mean when some text between b/b has been found that text is replaced 
with some Text, on second match, text between b/b is replaced by some other 
different text etc.

Btw, where I can find patterns that are valid?
(something like (\w+), (\d+)+i etc.

Thanks.
Regards.

[PHP] Web Fetch Process

2004-09-03 Thread Zoran
Hi

How can I parse HTML page which I fetched by PHP so some part of text would be 
replaced by other text.

For example, if I have bold text on HTML page (bSome text/b) how can I manage that 
all bold text on that page is replaced by some other text.

Also, I managed to delete all HTML code from page (with this code 
$data[0] = preg_replace(/([])+([^])+([.])*([])+/i,, $data[0]);

but also would like to delete all chars except numbers from page, can this be done?

Regards.
Zoran


Re: [PHP] Web Fetch Process

2004-09-03 Thread Jim Grill
From: Zoran [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, September 03, 2004 12:35 PM
Subject: [PHP] Web Fetch  Process


Hi

How can I parse HTML page which I fetched by PHP so some part of text would
be replaced by other text.

For example, if I have bold text on HTML page (bSome text/b) how can I
manage that all bold text on that page is replaced by some other text.

Also, I managed to delete all HTML code from page (with this code
$data[0] = preg_replace(/([])+([^])+([.])*([])+/i,, $data[0]);

but also would like to delete all chars except numbers from page, can this
be done?

Regards.
Zoran

Your first question:
To replace certain elements take a look at preg_replace()
http://us4.php.net/manual/en/function.preg-replace.php

Example:

$foo = 'stuff bsilly stuff/b more stuff';
echo preg_replace('/\b\(.*)\\/b\/', h1$1 lookie now/h1, $foo);

Your second question:
You could just use strip_tags()
http://us4.php.net/manual/en/function.strip-tags.php

Your last question:
To delete everything but numbers you could $content =
preg_replace('/[^\d]/','', $content);

Hope that helps

Jim Grill

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Web Fetch Process

2004-09-03 Thread raditha dissanayake
Zoran wrote:
Hi
How can I parse HTML page which I fetched by PHP so some part of text would be replaced by other text.
 

As jim has pointed out strip_tags is a good first step. However I have 
always believed that the best language for parsing html is perl and not 
PHP that's because there is a perl module (name HTMLParse) available 
from CPAN that behaves somewhat like the sax parse api  in PHP.

--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Web Fetch Process

2004-09-03 Thread Jim Grill
 Zoran wrote:

 Hi
 
 How can I parse HTML page which I fetched by PHP so some part of text
would be replaced by other text.
 
 
 As ucfirst(jim) has pointed out strip_tags is a good first step. However I
have
 always believed that the best language for parsing html is perl and not
 PHP that's because there is a perl module (name HTMLParse) available
 from CPAN that behaves somewhat like the sax parse api  in PHP.


Perl ???!!
a not perl! :-(

I'm tagging this one OT! :-)

Jim Grill

 -- 
 Raditha Dissanayake.
 
 http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
 Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
 Graphical User Inteface. Just 128 KB | with progress bar.

 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Fetch Information Via a link

2003-12-22 Thread Eric Holmstrom
Thankyou, put me on the right track :)

Jasper Bryant-Greene [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi Eric

 What you need to do is make another PHP page, maybe info.php, which will
 fetch the info field from the DB and display it.

 So for example, assuming the eventname field is unique, you could make
 the info like something like:

 a href=info.php?eventname=?=urlencode($eventname)?information/a

 And then make info.php fetch the info field from the DB, for example if
 you were using MySQL:

 // page header HTML here
 ?
 $row = mysql_fetch_assoc(mysql_query(SELECT info FROM table WHERE
 eventname='{$_GET['eventname']}'));
 $info = $row['info'];
 print(nl2br($info));
 ?
 // page footer HTML here

 Obviously you will need to change that to suit your site, and you may
 want to add some security to the $_GET variable being passed to the
 MySQL server to prevent attacks. Other than that, hope this helps.

 Regards

 Jasper Bryant-Greene
 Cabbage Promotions
 http://fatalnetwork.com/
 [EMAIL PROTECTED]


 Eric Holmstrom wrote:

  Hi there,
 
  I have this.
  Table Name = events
  Fields = eventname, date, info. Example
 
  ---
   EVENTS
  ---
  eventname |   date|  info
  --
  event1   |   0202  | info here
  --
  event2  |   0303  | info here 2
 
  The problem is that the field info has alot of text in it. When I
print
  this out in an array it makes a huge page due to each event having alot
of
  information. So im trying to make it so it will display the results like
  this.
 
  event10202infomation
  event20303infomation
 
  I want the word infomation to be hyperlinked, so if you click on it,
it
  will display the information in the info field. The problem is I don't
  know how to make a hyperlink that grabs the correct infomation for each
  event.
 
  Any help at all will be very grateful for.
 
  Thankyou
 
  Eric Holmstrom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Fetch Information Via a link

2003-12-21 Thread Jasper Bryant-Greene
Hi Eric

What you need to do is make another PHP page, maybe info.php, which will 
fetch the info field from the DB and display it.

So for example, assuming the eventname field is unique, you could make 
the info like something like:

a href=info.php?eventname=?=urlencode($eventname)?information/a

And then make info.php fetch the info field from the DB, for example if 
you were using MySQL:

// page header HTML here
?
$row = mysql_fetch_assoc(mysql_query(SELECT info FROM table WHERE 
eventname='{$_GET['eventname']}'));
$info = $row['info'];
print(nl2br($info));
?
// page footer HTML here

Obviously you will need to change that to suit your site, and you may 
want to add some security to the $_GET variable being passed to the 
MySQL server to prevent attacks. Other than that, hope this helps.

Regards

Jasper Bryant-Greene
Cabbage Promotions
http://fatalnetwork.com/
[EMAIL PROTECTED]
Eric Holmstrom wrote:

Hi there,

I have this.
Table Name = events
Fields = eventname, date, info. Example
---
 EVENTS
---
eventname |   date|  info
--
event1   |   0202  | info here
--
event2  |   0303  | info here 2
The problem is that the field info has alot of text in it. When I print
this out in an array it makes a huge page due to each event having alot of
information. So im trying to make it so it will display the results like
this.
event10202infomation
event20303infomation
I want the word infomation to be hyperlinked, so if you click on it, it
will display the information in the info field. The problem is I don't
know how to make a hyperlink that grabs the correct infomation for each
event.
Any help at all will be very grateful for.

Thankyou

Eric Holmstrom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-18 Thread Arne Rusek
On Mon, 17 Nov 2003 15:30:43 +, Curt Zirzow wrote:

 * Thus wrote Arne Rusek ([EMAIL PROTECTED]):

 Your problem exists here:
 
 Server API = Command Line Interface
 _ENV[SERVER_SOFTWARE] = Boa/0.94.13
 
 Seeing this tells me your webserver is not configured correctly,
 Boa should not be using the CLI version of php it should be using
 the CGI version.

Thank you, that was it. Boa can't run php directly. So i made php files
executable and added '#!/usr/bin/php4' at the beginning of the script.
Instead of that I should have used the cgi version, as you suggested,
which was /usr/lib/cgi-bin/php4.

Take care.

Arne Rusek

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-17 Thread Kim Steinhaug
I dont see the problem here at all, here is my test :
CutNpaste into your own environment ans save as .php file .

All I did was remove the php_info() so that variables dont get
messed up (apparently), and removed the error_reporting.

Result gives this :
array(3) { [username]= string(3) 123 [email]= string(3) 123
[submit]= string(10) Submit me! }

-
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html
head
 titleUntitled/title
/head
body
?php
//error_reporting(E_ALL);
echo pre\n;
//phpinfo();
echo /pre\nbr/;
var_dump($_POST);
?
form action=?=$PHP_SELF? method=POST
Your name: input type=text name=username/br/
Email: input type=text name=email//br
input type=submit name=submit value=Submit me!
/form
/body
/html
--

-- 
Kim Steinhaug
---
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
---


David T-G [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-17 Thread Ivan Marenic
Hi, Kim.

Your example is good but you missed the point here. Chris knows exactly
where my problem is.

Sending HTTP POST from mobile device is a bit different than using classic
web client. It shouldnt be, but it is.

Data is going trough WAP gateways, mobile operators proxeis ...

Worst case scenario is that some header items can be generated by
application, some by the phone's runtime, and others by the WAP gateway.

And those reaching the server might not be what we expect.

Regards,
Ivan







Kim Steinhaug [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I dont see the problem here at all, here is my test :
 CutNpaste into your own environment ans save as .php file .

 All I did was remove the php_info() so that variables dont get
 messed up (apparently), and removed the error_reporting.

 Result gives this :
 array(3) { [username]= string(3) 123 [email]= string(3) 123
 [submit]= string(10) Submit me! }

 -
 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
 html
 head
  titleUntitled/title
 /head
 body
 ?php
 //error_reporting(E_ALL);
 echo pre\n;
 //phpinfo();
 echo /pre\nbr/;
 var_dump($_POST);
 ?
 form action=?=$PHP_SELF? method=POST
 Your name: input type=text name=username/br/
 Email: input type=text name=email//br
 input type=submit name=submit value=Submit me!
 /form
 /body
 /html
 --

 -- 
 Kim Steinhaug
 ---
 There are 10 types of people when it comes to binary numbers:
 those who understand them, and those who don't.
 ---


 David T-G [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: thanks for the summary (was Re: [PHP] Can't fetch ...)

2003-11-17 Thread David T-G
Ivan --

...and then Ivan Marenic said...
% 
% Sending HTTP POST from mobile device is a bit different than using classic
% web client. It shouldnt be, but it is.

Ouch.  How very interesting.

I had missed that through this thread, so I'm really grateful for the
summary.  I'm even more grateful because one of the items on my feature
list is to allow customers to post pix directly from their phone cams; it
sounds like there could be some wrinkles in there.


Thanks again  HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


[PHP] Re: thanks for the summary (was Re: [PHP] Can't fetch ...)

2003-11-17 Thread Kim Steinhaug
Alrighty! That sheds some more light on this.
How exactly can I replicate this scenario then, using my mobile phone?

I have a Nokia 3610i i think, with MMS capabilituies and GPRS WAP.
Ive never accually thought of expanding website possibilities with this
use, how excatly do I post from my mobile?

It might be a dumb question, but when I know this I might be able to
look further into the problem.

-- 
Kim Steinhaug
---
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
---


David T-G [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-17 Thread Curt Zirzow
* Thus wrote Arne Rusek ([EMAIL PROTECTED]):
 
 If someone is interested in reading through the whole result it could
 be downloaded from
 
   http://zonk.matfyz.cz/php_post_problem

Your problem exists here:

Server API = Command Line Interface
_ENV[SERVER_SOFTWARE] = Boa/0.94.13

Seeing this tells me your webserver is not configured correctly,
Boa should not be using the CLI version of php it should be using
the CGI version.




Curt
-- 
My PHP key is worn out

  PHP List stats since 1997: 
http://zirzow.dyndns.org/html/mlists/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-17 Thread Curt Zirzow
* Thus wrote Ivan Marenic ([EMAIL PROTECTED]):
 I did not omit content.
 Copied whole text box in sniffer using context menu comands (select all,
 copy) - pasted to news agent.
 There is no content.

I didn't see the output of phpinfo or your print_r(). that leads me
to believe that your sniffer is only catching the headers.

Curt
-- 
My PHP key is worn out

  PHP List stats since 1997: 
http://zirzow.dyndns.org/html/mlists/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-16 Thread Arne Rusek
Hello.

On Sat, Nov 15, 2003 at 05:31:01PM -0800, Chris Shiflett wrote:
 That does seem strange. I glanced at this page of yours:
 
  http://zonk.matfyz.cz/php_post_problem
 
 And I saw this:
 
 REQUEST_METHOD = GET
 So, why was the request a GET request rather than a POST request? There is
 no content nor any entity headers either, so it doesn't seem like this
 line (telling us that the request method was GET) is wrong.
Sorry for that. Somehow me or my web browser tricked me into thinking I
saved the right file. There's a correct one now. I screwed it when I was
trying the GET method or whatever. Nonetheless it still does not work.
Neither with GET nor with POST. If you liked to glance a little bit more
maybe you'd like to see the request

http://zonk.matfyz.cz/request

It's the one used with the POST method. I sent this request to the
server with netcat and saved (hope that the right one that time:) the
result into

http://zonk.matfyz.cz/php_post_problem

again.

 However, I also don't see any URL variables, so it doesn't seem like the
 HTTP request contained any form data, whether GET or POST.
Whoa. What kind of variables did you say? Ok. This is what I thought: I
have a nonapache - boa - webserver, maybe it's POST handling could be
different. (That would be even more strange but maybe boa webserver does
not set these variables) So I'll try GET. You know how it ended. The
same way.

 echo $username;
 echo $_GET['username'];
 echo $_POST['username'];
 echo $_REQUEST['username'];
 echo $_SERVER['QUERY_STRING'];
Ok. I've put this little code of yours after var_dump($_GET):

array(0) { } 
Notice: Undefined variable: username in /home/zonk/public_html/test.php on line 11
Notice: Undefined index: username in /home/zonk/public_html/test.php on line 12
Notice: Undefined index: username in /home/zonk/public_html/test.php on line 13
Notice: Undefined index: username in /home/zonk/public_html/test.php on line 14
username=zonkemail=zonksubmit=Submit+me%21 

You see. It looks like the intrepreter hates me, doesn't it? :-)

 Hopefully one of this will output something relevant. Otherwise, I suppose
 it's possible that there is a bug in the CGI SAPI, unless I'm missing
 something.
Or we both. But it looks more like a bug to me because it should work
with no preceding actions taken.

 Hope that helps.
Oh thanks a lot. And apologies for wrong background info:)

Take care.

Arne Rusek

-- 
Arne Rusek [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-16 Thread Ivan Marenic
Solved all my problems with PERL.

Cheers.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-16 Thread David T-G
Ivan --

...and then Ivan Marenic said...
% 
% Solved all my problems with PERL.

Perl can be handy that way sometimes :-)

Care to tell us what the fix was, though, so that 1) future surfers can
know and 2) interested folks here might suggest how PHP can do it?


% 
% Cheers.


TIA  HTH  HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


[PHP] Can't fetch HTTP POST data in PHP?

2003-11-15 Thread Ivan Marenic
Any idea why?

I am sending HTTP post request from j2me mobile device.

Request is OK because it works well on ASP page.

Thanks for help!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-15 Thread Chris Shiflett
--- Ivan Marenic [EMAIL PROTECTED] wrote:
 Any idea why?
 
 I am sending HTTP post request from j2me mobile device.
 
 Request is OK because it works well on ASP page.

You have to provide some information if you want anyone to help you.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-15 Thread Ivan Marenic
Here is j2me code snippet:

byte[] postData=This is my test line! It works!
Yipi-Yai-Yee!!!.getBytes();

try{

c = (HttpConnection)Connector.open(url_post);
c.setRequestMethod(HttpConnection.POST);
c.setRequestProperty( User-Agent, Profile/MIDP-1.0
Configuration/CLDC-1.0 );
c.setRequestProperty( Content-Language, en-US );
c.setRequestProperty( Content-Type, text/plain);
c.setRequestProperty( Connection, close);
c.setRequestProperty( Content-Disposition,attachment;
name=\userfile\; filename=\userfile_txt\);
c.setRequestProperty( Content-Length, Integer.toString(
postData.length ) );

os = c.openOutputStream();
os.write( postData );
os.close();
os = null;


Here is PHP code snippet:

//Here I see HTTP method, and response is POST
:
echo $_SERVER['REQUEST_METHOD'];
:

:
// Show any post vars, but nothing shows - never!
if(count($_POST)0){
 echo POST.$new_line;
 print_r($_POST);
 echo $new_line;
}
:

// try with upload files array
if(count($_FILES)0){
 echo FILES.$new_line;
 print_r($_FILES);
 echo $new_line;
}


That's it.

Greetings,
Ivan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-15 Thread Ivan Marenic
Here is ASP code that works.

Dim binread
Dim bytecount

bytecount = Request.TotalBytes
binread = Request.BinaryRead(bytecount)

'Send response back to client
Response.BinaryWrite binread

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-15 Thread Chris Shiflett
--- Ivan Marenic [EMAIL PROTECTED] wrote:
 Here is j2me code snippet:

I try to avoid all of the crap that begins with the letter J, but your
example code looks like you are sending a POST request.

 Here is PHP code snippet:
 
 // Show any post vars, but nothing shows - never!
 if(count($_POST)0){
  echo POST.$new_line;
  print_r($_POST);
  echo $new_line;
 }

This looks you are expecting to receive a POST request with PHP. So, are
you wanting to send one or receive one?

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-15 Thread Ivan Marenic
 This looks you are expecting to receive a POST request with PHP. So, are
 you wanting to send one or receive one?

Receive one.


Chris Shiflett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 --- Ivan Marenic [EMAIL PROTECTED] wrote:
  Here is j2me code snippet:

 I try to avoid all of the crap that begins with the letter J, but your
 example code looks like you are sending a POST request.

  Here is PHP code snippet:
 
  // Show any post vars, but nothing shows - never!
  if(count($_POST)0){
   echo POST.$new_line;
   print_r($_POST);
   echo $new_line;
  }

 This looks you are expecting to receive a POST request with PHP. So, are
 you wanting to send one or receive one?

 Chris

 =
 Chris Shiflett - http://shiflett.org/

 PHP Security Handbook
  Coming mid-2004
 HTTP Developer's Handbook
  http://httphandbook.org/
 RAMP Training Courses
  http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-15 Thread Chris Shiflett
--- Ivan Marenic [EMAIL PROTECTED] wrote:
  This looks you are expecting to receive a POST request with PHP. So,
  are you wanting to send one or receive one?
 
 Receive one.

Is it possible for you to show us the HTTP request that is failing? It is
possible that it is malformed in some way that is fine with some Web
servers and not with others.

You might be able to use ethereal (http://www.ethereal.com/) to get the
HTTP request.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-15 Thread Ivan Marenic
 Is it possible for you to show us the HTTP request that is failing? It is
 possible that it is malformed in some way that is fine with some Web
 servers and not with others.

That may be possible but I am testing ASP i PHP(4.3.2) on same server IIS
5.0, localy.
Can't sniff that (Network adapter not in use)

Other, remote server I am using is Apache on RedHat Linux.

Here is failed POST REQUEST to that server:
*
POST /http_post.php HTTP/1.1

User-Agent: Profile/MIDP-1.0 Configuration/CLDC-1.0

Host: www.milleniumtip.com:80

Content-Disposition: attachment; name=userfile; filename=userfile_txt

Connection: close

Content-Type: text/plain

Content-Length: 47

Content-Language: en-US



Here is response:


HTTP/1.1 200 OK

Date: Sat, 15 Nov 2003 22:02:40 GMT

Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) mod_watch/3.12
mod_throttle/3.1.2 mod_gzip/1.3.19.1a mod_auth_pam/1.0a mod_ssl/2.8.11
OpenSSL/0.9.6e PHP/4.2.3 mod_perl/1.26 FrontPage/5.0.2.2510

X-Powered-By: PHP/4.2.3

Connection: close

Transfer-Encoding: chunked

Content-Type: text/html





 You might be able to use ethereal (http://www.ethereal.com/) to get the
 HTTP request.


For sniffing HTTP traffic I am using EffeTech HTTP Sniffer. Works OK.

Ivan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-15 Thread Chris Shiflett
--- Ivan Marenic [EMAIL PROTECTED] wrote:
 Here is failed POST REQUEST to that server:
 *
 POST /http_post.php HTTP/1.1
 User-Agent: Profile/MIDP-1.0 Configuration/CLDC-1.0
 Host: www.milleniumtip.com:80
 Content-Disposition: attachment; name=userfile;
filename=userfile_txt
 Connection: close
 Content-Type: text/plain
 Content-Length: 47
 Content-Language: en-US
 
 

That's the whole thing? If so, the problem seems to be a complete lack of
content. The Content-Length header specifies that 47 bytes are coming, and
Content-Type tells us that it is plain text, but there is nothing (it
should be after the blank line that follows Content-Language). Can you
check to see that you didn't omit this?

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-15 Thread Ivan Marenic
I did not omit content.
Copied whole text box in sniffer using context menu comands (select all,
copy) - pasted to news agent.
There is no content.

However, when using local server, on my desktop, I assume there is content
because I am getting response from ASP page with exact data wich is sent
from client.
PHP page responses exactly the same as the one on remote Apache server.

I have mental fog in my mind write now.





Chris Shiflett [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 --- Ivan Marenic [EMAIL PROTECTED] wrote:
  Here is failed POST REQUEST to that server:
  *
  POST /http_post.php HTTP/1.1
  User-Agent: Profile/MIDP-1.0 Configuration/CLDC-1.0
  Host: www.milleniumtip.com:80
  Content-Disposition: attachment; name=userfile;
 filename=userfile_txt
  Connection: close
  Content-Type: text/plain
  Content-Length: 47
  Content-Language: en-US
 
  

 That's the whole thing? If so, the problem seems to be a complete lack of
 content. The Content-Length header specifies that 47 bytes are coming, and
 Content-Type tells us that it is plain text, but there is nothing (it
 should be after the blank line that follows Content-Language). Can you
 check to see that you didn't omit this?

 Chris

 =
 Chris Shiflett - http://shiflett.org/

 PHP Security Handbook
  Coming mid-2004
 HTTP Developer's Handbook
  http://httphandbook.org/
 RAMP Training Courses
  http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-15 Thread Arne Rusek
Hello.

I read throughout this thread and it looks like I have encountered
the same problem. Everything looks just fine but somehow the PHP
does not parse the request data sent to the script. I did some research on
that but gave up since I couldn't find how and where those data were
parsed. But I've used the PHP for a few days maybe it's just my
stupidity. Some of you more acquainted with the topic will find some info
I've gathered useful eventually.

I used this form:

form action=test.php method=POST
Your name: input type=text name=username/br/
Email: input type=text name=email//br
input type=submit name=submit value=Submit me!
/form

The test.php script contained this code:

?php
error_reporting(E_ALL);
echo pre\n;
phpinfo();
echo /pre\nbr/;
var_dump($_POST);
?

Then I saw a pretty large page but at the end there was

array(0) { }

and _that_ seemed to me pretty strange.

If someone is interested in reading through the whole result it could
be downloaded from

http://zonk.matfyz.cz/php_post_problem

I tried to change the method to GET but it didn't work either. The result
could be seen at

http://zonk.matfyz.cz/php_get_problem

Take care.

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Arne Rusek [EMAIL PROTECTED]
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Resistance is futile. Open your source code and prepare for assimilation.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can't fetch HTTP POST data in PHP?

2003-11-15 Thread Chris Shiflett
--- Arne Rusek [EMAIL PROTECTED] wrote:
 I used this form:
 
 form action=test.php method=POST
   Your name: input type=text name=username/br/
   Email: input type=text name=email//br
   input type=submit name=submit value=Submit me!
 /form
 
 The test.php script contained this code:
 
 ?php
   error_reporting(E_ALL);
   echo pre\n;
   phpinfo();
   echo /pre\nbr/;
   var_dump($_POST);
 ?
 
 Then I saw a pretty large page but at the end there was
 
   array(0) { }
 
 and _that_ seemed to me pretty strange.

That does seem strange. I glanced at this page of yours:

 http://zonk.matfyz.cz/php_post_problem

And I saw this:

REQUEST_METHOD = GET

So, why was the request a GET request rather than a POST request? There is
no content nor any entity headers either, so it doesn't seem like this
line (telling us that the request method was GET) is wrong.

However, I also don't see any URL variables, so it doesn't seem like the
HTTP request contained any form data, whether GET or POST.

 http://zonk.matfyz.cz/php_get_problem

This looks a bit better. We still have a GET request method, and the query
string has something:

QUERY_STRING = username=zonkemail=zonksubmit=Submit+me%21

However, I can't explain why a print_r($_GET) would not display the
username, email, and submit form variables. Maybe you can try:

echo $username;
echo $_GET['username'];
echo $_POST['username'];
echo $_REQUEST['username'];
echo $_SERVER['QUERY_STRING'];

Hopefully one of this will output something relevant. Otherwise, I suppose
it's possible that there is a bug in the CGI SAPI, unless I'm missing
something.

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security Handbook
 Coming mid-2004
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: fetch then put record?

2003-06-15 Thread Don Read

On 10-Jun-2003 Jean-Christian Imbeault wrote:
 [reply to a personal email posted here for the benefit of all :)]
 

snip 

   This bugs me because my db has 125 fields and it will be a very long 
 sql string!
 
 I bet!
 
   The form page generates form contents by using a while loop.
  
   How would you build the sql string from the form page?
 
 Use a while loop ;) Name the GET or POST vars the same as the field 
 names in the DB. Then you could use something like (I say like b/c this 
 won't work, it's just an idea):
 
 $sql = update table A SET ;
 while (list($fieldName, $value) == each($_POST)) {
$sql .=  $fieldName='$value', ;
 }
 
 This won't work because there will be POST values passes in that are not 
 part of your form data. Oh, and there will be a trailing , you need to 
 trim off ...
 
 Just a quick idea.

You can make it a little smarter:

//refetch the old row ...

$qry=SELECT * FROM tbl WHERE id= .$_POST['id'];
$r=mysql_query($qry);
$row=mysql_fetch_array($r);

unset($chgflds);
foreach($row as $fld = $val) {
   if (isset($_POST[$fld])  ($_POST[$fld] != $val)) {
  $chgflds[] = $fld=' .$_POST[$fld] .';
   }
}

$update='UPDATE tbl SET ' .implode(', ', $chgflds) 
.'WHERE id=' .$_POST['id'];
 
mysql_query($update);


Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: fetch then put record?

2003-06-09 Thread Jean-Christian Imbeault
Steve B. wrote:
Hello,
In ASP you can set records fields then call a dbupdate function.
There is no such function in PHP.

It appears mysql only supports update with the UPDATE query?
Huh ... MySQL is a database. It understands SQL. dbupdate() is an ASP 
function ... don't blame MySQL if it doesn't understand ASP ;) The only 
way to update data in MySQL is to use SQL, and in SQL to update data you 
use UPDATE queries :)

Here is my code:

$dbrec=getrec($result);
This is not PHP code. There is no function called getrec().

If you want to access a MySQL database using PHP you will also need to 
learn SQL. You need to learn how to write SQL update queries ...

I suggest that you read the PHP online manual and learn all about the 
MySQL functions. Read this section and then try again:

http://jp.php.net/manual/en/ref.mysql.php

Jean-Christian



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: fetch then put record?

2003-06-09 Thread Jean-Christian Imbeault
[reply to a personal email posted here for the benefit of all :)]

 Are you sure you can't?

Yes.

 Could ASP do something that MySQL/SQL can't?

You confusing apples and oranges ... ASP is not a database. You should 
be comparing ASP to PHP.

So the short answer is PHP does not have an equivalent function to ASP's 
update() or whatever it is.

 That is very strange.

No it isn't. These are different languages.

 I wonder what mode ASP is accessing DB which lets you set record 
variables then paste them into
 it?

A very bad mode I would think. Very dangerous. But I can see how it is 
convenient.

 Perhaps it just does an update in the background.

Of course. No you understand. ASP is using a convenience method that 
does all that ugly SQL updating in the background. As far as I know PHP 
does not have such functionality.

 This bugs me because my db has 125 fields and it will be a very long 
sql string!

I bet!

 The form page generates form contents by using a while loop.

 How would you build the sql string from the form page?
Use a while loop ;) Name the GET or POST vars the same as the field 
names in the DB. Then you could use something like (I say like b/c this 
won't work, it's just an idea):

$sql = update table A SET ;
while (list($fieldName, $value) == each($_POST)) {
  $sql .=  $fieldName='$value', ;
}
This won't work because there will be POST values passes in that are not 
part of your form data. Oh, and there will be a trailing , you need to 
trim off ...

Just a quick idea.

--

Jean-Christian Imbeault

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] MySQL fetch data

2002-06-27 Thread Jefferson Cowart

Is there any way to return all the rows returned by a mysql query with
one command. Currently I have to run through a for or while loop the
same number of times as there are rows and take that row and copy it to
an array. I end up with an array of arrays but it seems like it would be
a common enough problem that the function would already exist. 


Thanks
Jefferson Cowart
[EMAIL PROTECTED] 

Support Open Instant Messaging Protocols
http://www.petitiononline.com/openIM/petition.html


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] MySQL fetch data

2002-06-27 Thread Jason Wong

On Thursday 27 June 2002 16:20, Jefferson Cowart wrote:
 Is there any way to return all the rows returned by a mysql query with
 one command. 

I don't think there is a built-in command to do so. 

 Currently I have to run through a for or while loop the
 same number of times as there are rows and take that row and copy it to
 an array. I end up with an array of arrays

No need to use a for loop, I prefer to use a while loop.

 but it seems like it would be
 a common enough problem that the function would already exist.

Once you have the code working just wrap it up in a function or a class and 
away you go.

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
My pants just went to high school in the Carlsbad Caverns!!!
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] MySQL fetch data

2002-06-27 Thread John Holmes

 Is there any way to return all the rows returned by a mysql query with
 one command. Currently I have to run through a for or while loop the
 same number of times as there are rows and take that row and copy it
to
 an array. I end up with an array of arrays but it seems like it would
be
 a common enough problem that the function would already exist.

No. Write your own wrapper function for MySQL_query() that does it for
you...put it in a classuse it. Some abstraction layers that are out
there may provide functions that do this for you, though. I generally
avoid doing such things if I have to, that way I'm not wasting a bunch
of memory in PHP by creating these huge arrays...

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] MySQL fetch data

2002-06-27 Thread Chris Hewitt

Jefferson,

I am wondering why you would want to do this. If you get the sql 
statement to order the rows the way you need to use them then there 
should not be a need to refer back to earlier rows. I sometimes need to 
know if one field has the same value as in the previous record, so I 
keep its value in a simple variable so I know if, for example, it is for 
the same customer or not. I have never found it necessary to refer back 
an arbitary number of rows, so hence the question.

I wonder if you are trying to do too much in a single sql statement?

Regards

Chris

Jefferson Cowart wrote:

Is there any way to return all the rows returned by a mysql query with
one command. Currently I have to run through a for or while loop the
same number of times as there are rows and take that row and copy it to
an array. I end up with an array of arrays but it seems like it would be
a common enough problem that the function would already exist. 




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] MySQL fetch data

2002-06-27 Thread Erik Price


On Thursday, June 27, 2002, at 04:20  AM, Jefferson Cowart wrote:

 Is there any way to return all the rows returned by a mysql query with
 one command. Currently I have to run through a for or while loop the
 same number of times as there are rows and take that row and copy it to
 an array. I end up with an array of arrays but it seems like it would be
 a common enough problem that the function would already exist.

You will probably always need to use a looping construct to grab your 
data (otherwise how will you assign each value to a variable?).  But you 
may find it easier to use mysql_fetch_object().
http://www.php.net/manual/en/function.mysql-fetch-object.php

Or maybe not.  It's a matter of preference and performance (I think the 
object version is a bit more expensive).


Erik






Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Sybase Fetch Array Question

2002-06-24 Thread B i g D o g

Can someone let me know when you call sybase_fetch_array that the internal
row pointer of the sybase result is increased.  So that subsequent calls
using sybase_fetch_array will return a result 1 more than the previous
result return?


Okay that was weird


B i g D o g



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Sybase Fetch Array Question

2002-06-24 Thread 1LT John W. Holmes

 Can someone let me know when you call sybase_fetch_array that the internal
 row pointer of the sybase result is increased.  So that subsequent calls
 using sybase_fetch_array will return a result 1 more than the previous
 result return?

Hey, I just wanted to let you know that when you call sybase_fetch_array
that the internal row pointer of the sybase result is increased. I had a
feeling you wanted to know that. Also, you should know that subsequent calls
using sybase_fetch_array will return a result 1 more than the previous
result return.

Documentation is at www.php.net/sybase_fetch_row

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] mysql fetch field

2002-03-17 Thread caspar kennerdale

I seem to be getting unexpected information from a mysql fetch field query.

My table has three fields- here is the schema-

CREATE TABLE template (
   id smallint(6) NOT NULL auto_increment,
   name mediumtext NOT NULL,
   multiple tinyint(4) DEFAULT '0' NOT NULL,
   PRIMARY KEY (id),
   UNIQUE id (id)
);


Using the samplecode on php.net to output an object containing the
properties of eacj field I have been able to output the following

Blob - 0
MaxLength - 1
Multiple Key - 0
Name - id
Not Null - 1
Numeric - 1
Primary Key - 1
Table - template
Type - int
Unique Key - 1
Unsigned - 0
ZeroFill - 0

Blob - 1
MaxLength - 7
Multiple Key - 0
Name - name
Not Null - 1
Numeric - 0
Primary Key - 0
Table - template
Type - blob
Unique Key - 0
Unsigned - 0
ZeroFill - 0

Blob - 0
MaxLength - 1
Multiple Key - 0
Name - multiple
Not Null - 1
Numeric - 1
Primary Key - 0
Table - template
Type - unknown
Unique Key - 0
Unsigned - 0
ZeroFill - 0

Which strange as the first field is specified as having a max length of 1
yet it is a small int with a length of 6.
Likewise the second field is specified as a blob with a maximum length of 7-
yet in my schema it is a medium text.
And again my third field is listed as havingan unkniwn typeyet in the schema
it is a tinyint

Here is my code

$TableInfo = new DB;
$TableInfoArray = $TableInfo -MySqlGetTableInfo('SELECT * FROM
template');
$a =-1;
$b = -1;
while (++$a  count($TableInfoArray)){
$Content[++$b]  = Blob - .$TableInfoArray[$a][0].br;
$Content[++$b]  = MaxLength - .$TableInfoArray[$a][1].br;
$Content[++$b]  = Multiple Key - .$TableInfoArray[$a][2].br;
$Content[++$b]  = Name - .$TableInfoArray[$a][3].br;
$Content[++$b]  = Not Null - .$TableInfoArray[$a][4].br;
$Content[++$b]  = Numeric - .$TableInfoArray[$a][5].br;
$Content[++$b]  = Primary Key - .$TableInfoArray[$a][6].br;
$Content[++$b]  = Table - .$TableInfoArray[$a][7].br;
$Content[++$b]  = Type - .$TableInfoArray[$a][8].br;
$Content[++$b]  = Unique Key - .$TableInfoArray[$a][9].br;
$Content[++$b]  = Unsigned - .$TableInfoArray[$a][10].br;
$Content[++$b]  = ZeroFill - .$TableInfoArray[$a][11].br;
$Content[++$b]  = br;
}
$Content = join('', $Content);
return $Content;


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] mysql fetch field

2002-03-17 Thread caspar kennerdale

Actually I've alreasdy worked it out- sorry

-Original Message-
From: caspar kennerdale [mailto:[EMAIL PROTECTED]]
Sent: 17 March 2002 10:31
To: [EMAIL PROTECTED]
Subject: [PHP] mysql fetch field


I seem to be getting unexpected information from a mysql fetch field query.

My table has three fields- here is the schema-

CREATE TABLE template (
   id smallint(6) NOT NULL auto_increment,
   name mediumtext NOT NULL,
   multiple tinyint(4) DEFAULT '0' NOT NULL,
   PRIMARY KEY (id),
   UNIQUE id (id)
);


Using the samplecode on php.net to output an object containing the
properties of eacj field I have been able to output the following

Blob - 0
MaxLength - 1
Multiple Key - 0
Name - id
Not Null - 1
Numeric - 1
Primary Key - 1
Table - template
Type - int
Unique Key - 1
Unsigned - 0
ZeroFill - 0

Blob - 1
MaxLength - 7
Multiple Key - 0
Name - name
Not Null - 1
Numeric - 0
Primary Key - 0
Table - template
Type - blob
Unique Key - 0
Unsigned - 0
ZeroFill - 0

Blob - 0
MaxLength - 1
Multiple Key - 0
Name - multiple
Not Null - 1
Numeric - 1
Primary Key - 0
Table - template
Type - unknown
Unique Key - 0
Unsigned - 0
ZeroFill - 0

Which strange as the first field is specified as having a max length of 1
yet it is a small int with a length of 6.
Likewise the second field is specified as a blob with a maximum length of 7-
yet in my schema it is a medium text.
And again my third field is listed as havingan unkniwn typeyet in the schema
it is a tinyint

Here is my code

$TableInfo = new DB;
$TableInfoArray = $TableInfo -MySqlGetTableInfo('SELECT * FROM
template');
$a =-1;
$b = -1;
while (++$a  count($TableInfoArray)){
$Content[++$b]  = Blob - .$TableInfoArray[$a][0].br;
$Content[++$b]  = MaxLength - .$TableInfoArray[$a][1].br;
$Content[++$b]  = Multiple Key - .$TableInfoArray[$a][2].br;
$Content[++$b]  = Name - .$TableInfoArray[$a][3].br;
$Content[++$b]  = Not Null - .$TableInfoArray[$a][4].br;
$Content[++$b]  = Numeric - .$TableInfoArray[$a][5].br;
$Content[++$b]  = Primary Key - .$TableInfoArray[$a][6].br;
$Content[++$b]  = Table - .$TableInfoArray[$a][7].br;
$Content[++$b]  = Type - .$TableInfoArray[$a][8].br;
$Content[++$b]  = Unique Key - .$TableInfoArray[$a][9].br;
$Content[++$b]  = Unsigned - .$TableInfoArray[$a][10].br;
$Content[++$b]  = ZeroFill - .$TableInfoArray[$a][11].br;
$Content[++$b]  = br;
}
$Content = join('', $Content);
return $Content;


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] no fetch

2001-04-24 Thread Wilbert Enserink

Hello everybody,

I'm just starting out with php4 and I can use some help.
Below is a script I wrote. The dbase connections are allright (i have tested
them) , but the final result is 'no fetch'.
so something goes wrong in 'mysql_fetch_row' but I don't understand what.
Any of you have an idea?

Thanx.

W. Enserink


?php

$global_dbh = mysql_connect($hostname, $user, $password);

if(!$global_dbh)
 die(no dbase connection);

$a = mysql_select_db('pdd', $global_dbh);
if(!$a)
 die(no dbase selection);


function display_db_table($tablename, $connection)
{
 $query_string = select * from $tablename;
 print (querystring = $query_stringBR);
 $result_id = mysql_query($query_string, $connection);
 print(result_id = $result_idBR);
 $column_count = mysql_num_fields($result_id);
 print(column_count = $column_countBR);



print(TABLE BORDER=1\n);
while ($row = mysql_fetch_row($result_id));
 {
 if(!$row)
  die (no fetch);
 print row = $row[1];
 print(tr align = left valign = top);
 for ($column_num = 0;
  $column_num  $column_count;
  $column_num++)
 print(TD$row[$column_num] $column_num/td\n);

 print(/tr\n);
 }
print(/table\n);
}
?

html
body
tabletrtd
?php
display_db_table(test, $global_dbh);

?
/TD/TR/TABLE
/body
/html

-
Pas de Deux
Van Mierisstraat 25
2526 NM Den Haag
tel 070 4450855
fax 070 4450852
http://www.pdd.nl
[EMAIL PROTECTED]
-

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]