php-general Digest 28 Dec 2005 15:43:32 -0000 Issue 3875

Topics (messages 227911 through 227935):

mysqli module in php 4
        227911 by: Bagus Nugroho
        227916 by: M. Sokolewicz
        227917 by: Paul Waring
        227930 by: John Nichel

Re: PHP Frameworks
        227912 by: Ruben Rubio Rey

SELECT?
        227913 by: William Stokes
        227914 by: Christian Ista
        227915 by: Max Schwanekamp
        227919 by: Paul Waring
        227922 by: Zareef Ahmed

Re: xmlspecialchars
        227918 by: Jochem Maas

list a query
        227920 by: Ross
        227921 by: Jochem Maas

download not working
        227923 by: Ross
        227924 by: Jochem Maas
        227925 by: Ross
        227927 by: Albert
        227928 by: Albert

PDO & pdo_odbc
        227926 by: Markus Fischer

error: Process limit exceeded for uid 10337 [25 >= 24]
        227929 by: Cesar Cruz

Location ....
        227931 by: Christian Ista
        227932 by: Jay Blanchard
        227933 by: Silvio Porcellana [tradeOver]
        227935 by: Christian Ista

pdo_informix
        227934 by: Aleksander

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 ---
Hi All,

Is mysqli module enable by default on php 4 as mysql module.

If not enable by default, where I can get this module(hopefully  a direct link 
to download)

Thanks in advance

 


--- End Message ---
--- Begin Message ---
Bagus Nugroho wrote:
Hi All,

Is mysqli module enable by default on php 4 as mysql module.
no

If not enable by default, where I can get this module(hopefully  a direct link 
to download)
you can't, it *requires* PHP 5

Thanks in advance



--- End Message ---
--- Begin Message ---
On 12/28/05, Bagus Nugroho <[EMAIL PROTECTED]> wrote:
> Is mysqli module enable by default on php 4 as mysql module.

No, because it's a PHP5 module (if you look at the documentation for
it, all the php.ini settings for it have only been available since
5.0.0).

> If not enable by default, where I can get this module(hopefully  a direct 
> link to download)

I've heard rumours of people getting it installed/running under PHP 4,
but I'm not sure if you really can or not. There is no direct
download, the installation section of the mysqli extension page tells
you how to get it to work:

http://www.php.net/mysqli

Paul

--
Data Circle
http://datacircle.org

--- End Message ---
--- Begin Message ---
M. Sokolewicz wrote:
Bagus Nugroho wrote:

Hi All,

Is mysqli module enable by default on php 4 as mysql module.

no

If not enable by default, where I can get this module(hopefully a direct link to download)

you can't, it *requires* PHP 5

I've been running mysqli on 4.3.x and 4.4

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Script Head wrote:

Nobody has mentioned Fusebox (www.fusebox.org). I have been using it to
develop PHP applications for about 2 years. It has proven to be extremely
flexible when a large number of developers collaborate on one project.

jedit :)
Love macros and plugins!
http://www.jedit.org/

--- End Message ---
--- Begin Message ---
Hello,

I have one MySQL table with about 500 rows. I need to read the table one row 
at a
time, make some changes to data in one field and then store the changed data
to another table.

I'm using PHP to change the data but I have no idea how to select one row at
a time from the DB table. There's one auto-increment id field in the table
but the id's doesn't start from 1 and are not sequential.

Any ideas or help is much appreciated!

Thanks
-Will

--- End Message ---
--- Begin Message ---
> From: William Stokes [mailto:[EMAIL PROTECTED]
> I have one MySQL table with about 500 rows. I need to read the table one
> row at a time, make some changes to data in one field and then store the 
> changed data to another table.

1. May be add a column, CHANGED_FL with default value N.
2. Select to find the ID minimum with a select CHANGED_FL is N
3. Select the row with the ID found above and make you business
4. Make change and change CHANGED_FL to Y

Repeat operation 2 to 4 

C.

--- End Message ---
--- Begin Message ---
William Stokes wrote:
I have one MySQL table with about 500 rows. I need to read the table one row at a
time, make some changes to data in one field and then store the changed data
to another table.
I'm using PHP to change the data but I have no idea how to select one row at
a time from the DB table.

A couple of possible options, depending on your specific situation:
1. Use INSERT...SELECT syntax. If you're doing a regular transformation on all selected rows that can be handled by MySQL function(s), this would be easiest and fastest. e.g. (table_b.id is an auto-incremented primary key):
INSERT INTO table_b (id, table_a_id, transformed_value)
SELECT NULL, id, SOME_FUNCTION(mycolumn)
FROM table_a

2. Depending on the size of the records, you might want to just read all 500 rows into a two-dimensional array and use an array fn such as array_walk to apply a function to change the relevant data and insert into your new table. To get all rows into an array, you set an array variable and iterate over the MySQL result set to build the members of the array.

If you need details on how to do *that*, you'll need to indicate which version of PHP you're using and whether you're using an abstraction layer for database access. For an example in PHP 4, you might have:
$db_cursor = mysql_query("SELECT * FROM my_table", $db);
//check for errors [omitted]
//count the records
$recordcount = mysql_num_rows($db_cursor);
//assemble the recordset array
$recordset = array();
for($i=0;$i<$recordcount; $i++)
{
    $recordset[] = mysql_fetch_assoc($db_cursor);               
}
//clean up, etc. [omitted]

Then use array_walk() or similar...

HTH

--
Max Schwanekamp
http://www.neptunewebworks.com/

--- End Message ---
--- Begin Message ---
On 12/28/05, William Stokes <[EMAIL PROTECTED]> wrote:
> I have one MySQL table with about 500 rows. I need to read the table one row
> at a
> time, make some changes to data in one field and then store the changed data
> to another table.
>
> I'm using PHP to change the data but I have no idea how to select one row at
> a time from the DB table. There's one auto-increment id field in the table
> but the id's doesn't start from 1 and are not sequential.
>
> Any ideas or help is much appreciated!

Can you not just fetch all the data at once like so:

$result = mysql_query("SELECT * FROM mytable");

then iterate over the results:

while ( $row = mysql_fetch_assoc($result) )
{
    mysql_query("INSERT INTO othertable (column1) VALUES (" .
$row['column_x'] . ");
}

The only thing you'd have to be careful with is the maximum execution
time settings if you're running this script over the web, as opposed
to on the command line. If you're only making changes to 500 rows
though it shouldn't take too long - I've restored thousands of rows to
a database before and that took less than a second.

Paul

--
Data Circle
http://datacircle.org

--- End Message ---
--- Begin Message ---
Hi,

        As there are only 500 rows, there is not any harm in fetching all
records through one query and then do the update between while loop


$query="select * from table";
$result=mysql_query($query);

while($row=mysql_fetch_array($result))
{
$newquery="update YOUR STATEMENT where uniquefield like
$row['uniquefield']";
mysql_query($newquery);
}


if you really need to fetch only one record at a time, you can use the LIMIT
keyword in your SQL statement, and can create the script as needed.


Zareef Ahmed

----- Original Message ----- 
From: "Christian Ista" <[EMAIL PROTECTED]>
To: "'William Stokes'" <[EMAIL PROTECTED]>; <[email protected]>
Sent: Wednesday, December 28, 2005 3:57 AM
Subject: RE: [PHP] SELECT?


> > From: William Stokes [mailto:[EMAIL PROTECTED]
> > I have one MySQL table with about 500 rows. I need to read the table one
> > row at a time, make some changes to data in one field and then store the
> > changed data to another table.
>
> 1. May be add a column, CHANGED_FL with default value N.
> 2. Select to find the ID minimum with a select CHANGED_FL is N
> 3. Select the row with the ID found above and make you business
> 4. Make change and change CHANGED_FL to Y
>
> Repeat operation 2 to 4
>
> C.
>


====================================================
PHP Expert Consultancy in Development  http://www.indiaphp.com
Yahoo! : consultant_php MSN : [EMAIL PROTECTED]

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

--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
I'm creating some XML data, but not using any of the built-in PHP XML
functions, as they are not necessarily available on all servers.

I need to encode Data (CDATA) such as URLs etc.

htmlspecialchars() works on all my test cases so far, but is it
"right"?...

I don't think so - not completely - actually this is shaky ground for
me but one I'm very interested in (encoding/charsets/etc).

I'm pretty sure you can do this for example:

<sometag>
        <![CDATA[<em>This is <a 
href="www.iamjochem.com/?i=1&amp;j=2">HTML</a></em>]]>
</sometag>

now I don't think that an XML parser will care if the href attribute's value is
encoded properly (e.g. the '&' given as '&amp;') because the whole CDATA block
is just a string (UTF8 is the default everywhere I have played with XML, so 
beware
that if you don't specify your character encoding that ti might cause hiccups).
so in the case above wether you entity encoding the url or not is pureluy a 
matter
of how valid do you want the HTML that one can extract from the CDATA block
inside the <sometag> tag.

the following urls might throw some light on the issue for you:

http://xmlrpc-epi.sourceforge.net/main.php?t=samples
http://blogs.law.harvard.edu/tech/encodingDescriptions


Please cc: me on replies -- I'm way behind on PHP General reading... :-(


--- End Message ---
--- Begin Message ---
What does 'list' do in a php query?

$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);


found it in this example...

http://www.php-mysql-tutorial.com/php-mysql-upload.php 

--- End Message ---
--- Begin Message ---
Ross wrote:
What does 'list' do in a php query?

there is no such thing a php query (unless you count asking a pph
related question). list() is a language construct
an explanation of it can be found in the manual

http://php.net/list

please always read/search the manual before asking question.


$result = mysql_query($query) or die('Error, query failed');
list($name, $type, $size, $content) = mysql_fetch_array($result);


found it in this example...

http://www.php-mysql-tutorial.com/php-mysql-upload.php

--- End Message ---
--- Begin Message ---
working form this example

http://www.php-mysql-tutorial.com/php-mysql-upload.php


my code is as follows, all I get is a corrupt pdf file.....

$query= "SELECT * FROM publications WHERE alphabet='a'";

 $result= mysql_query($query);
   while  ($row = @mysql_fetch_array($result, MYSQL_ASSOC)){

    $row['pdf_size'] = $row['pdf_size']/ 1024;
 $row['pdf_size']= number_format($row['pdf_size'], 0);
 $size= $row['pdf_size'];
$name = str_replace("_", " ", $row['pdf_name']);
$name = str_replace(".pdf", "", $name);
$link= $row['content'];

echo "<span class=\"pdflinks\">$name</span>";
echo "&nbsp;&nbsp;";
echo "<span class=\"sizes\">($size kb)</span>";
//<a href="#">ross</a>
?>
download is here......
<a href="a-z.php?id=<?=$row['id'];?>">link</a> <br>
<?

if(isset($_GET['id']))
{
 echo "id is this";
$id    = $_GET['id'];
$query = "SELECT * FROM publications WHERE id = '$id'";

$result = mysql_query($query) or die('Error, query failed');

$pdf_size=$row['pdf_size'];
$pdf_type=$row['pdf_type'];
$pdf_name=$row['pdf_name'];
ob_clean();
header("Content-length: $pdf_size");
header("Content-type: $pdf_type");
header("Content-Disposition: attachment; filename=$pdf_name");
echo $content;


exit;
}
}

--- End Message ---
--- Begin Message ---
are people supposed to smell what is not working?
do you get any errors? is it possible the PDF was corrupt
when you uploaded it?

Ross wrote:
working form this example

http://www.php-mysql-tutorial.com/php-mysql-upload.php


my code is as follows, all I get is a corrupt pdf file.....

$query= "SELECT * FROM publications WHERE alphabet='a'";

 $result= mysql_query($query);
   while  ($row = @mysql_fetch_array($result, MYSQL_ASSOC)){

    $row['pdf_size'] = $row['pdf_size']/ 1024;
 $row['pdf_size']= number_format($row['pdf_size'], 0);
 $size= $row['pdf_size'];
$name = str_replace("_", " ", $row['pdf_name']);
$name = str_replace(".pdf", "", $name);
$link= $row['content'];

echo "<span class=\"pdflinks\">$name</span>";
echo "&nbsp;&nbsp;";
echo "<span class=\"sizes\">($size kb)</span>";
//<a href="#">ross</a>
?>
download is here......
<a href="a-z.php?id=<?=$row['id'];?>">link</a> <br>
<?

if(isset($_GET['id']))
{
 echo "id is this";
$id    = $_GET['id'];
$query = "SELECT * FROM publications WHERE id = '$id'";

$result = mysql_query($query) or die('Error, query failed');

$pdf_size=$row['pdf_size'];
$pdf_type=$row['pdf_type'];
$pdf_name=$row['pdf_name'];
ob_clean();
header("Content-length: $pdf_size");
header("Content-type: $pdf_type");
header("Content-Disposition: attachment; filename=$pdf_name");
echo $content;


exit;
}
}


--- End Message ---
--- Begin Message ---
The pdf is fine, there are no errors . All I get is a small (130byte) pdf 
file which is corrupt when I try and open it.

Thanks,

R.

"Jochem Maas" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> are people supposed to smell what is not working?
> do you get any errors? is it possible the PDF was corrupt
> when you uploaded it?
>
> Ross wrote:
>> working form this example
>>
>> http://www.php-mysql-tutorial.com/php-mysql-upload.php
>>
>>
>> my code is as follows, all I get is a corrupt pdf file.....
>>
>> $query= "SELECT * FROM publications WHERE alphabet='a'";
>>
>>  $result= mysql_query($query);
>>    while  ($row = @mysql_fetch_array($result, MYSQL_ASSOC)){
>>
>>     $row['pdf_size'] = $row['pdf_size']/ 1024;
>>  $row['pdf_size']= number_format($row['pdf_size'], 0);
>>  $size= $row['pdf_size'];
>> $name = str_replace("_", " ", $row['pdf_name']);
>> $name = str_replace(".pdf", "", $name);
>> $link= $row['content'];
>>
>> echo "<span class=\"pdflinks\">$name</span>";
>> echo "&nbsp;&nbsp;";
>> echo "<span class=\"sizes\">($size kb)</span>";
>> //<a href="#">ross</a>
>> ?>
>> download is here......
>> <a href="a-z.php?id=<?=$row['id'];?>">link</a> <br>
>> <?
>>
>> if(isset($_GET['id']))
>> {
>>  echo "id is this";
>> $id    = $_GET['id'];
>> $query = "SELECT * FROM publications WHERE id = '$id'";
>>
>> $result = mysql_query($query) or die('Error, query failed');
>>
>> $pdf_size=$row['pdf_size'];
>> $pdf_type=$row['pdf_type'];
>> $pdf_name=$row['pdf_name'];
>> ob_clean();
>> header("Content-length: $pdf_size");
>> header("Content-type: $pdf_type");
>> header("Content-Disposition: attachment; filename=$pdf_name");
>> echo $content;
>>
>>
>> exit;
>> }
>> }
>> 

--- End Message ---
--- Begin Message ---
Ross wrote:
> The pdf is fine, there are no errors . All I get is a small (130byte) pdf 
> file which is corrupt when I try and open it.

>From the code I gather you are saving the uploaded file in the database. 
1 - What field type are you using for this? 
2 - Are you using some form of encoding (eg base64_encode()) before writing
it database and decoding when reading it from the database?
3 - Why not save the file to disk with a reference to the correct filename
in the database? It will most probably solve your issue.

I have tried this saving the file into the database before and could only
get it to work reliably by:
- base64_encode() on the content of the file
- keeping the files below 100kbyte (It was way back with MySQL 3.x and it
seemed that MySQL couldn’t save such large amounts of data in a blob or text
field

I ended up uploading it to disk into a directory not accessible to someone
from the outside but accessible by the user Apache was running as. Then by
reading the content from the file with PHP and outputting in a similar
method as you are using.

Hope it helps

Albert

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.8/215 - Release Date: 2005/12/27
 

--- End Message ---
--- Begin Message ---
> Ross wrote:
>> $query= "SELECT * FROM publications WHERE alphabet='a'";
>>
>>  $result= mysql_query($query);
>>    while  ($row = @mysql_fetch_array($result, MYSQL_ASSOC)){
>>
>>     $row['pdf_size'] = $row['pdf_size']/ 1024;
>>  $row['pdf_size']= number_format($row['pdf_size'], 0);
>>  $size= $row['pdf_size'];
>> $name = str_replace("_", " ", $row['pdf_name']);
>> $name = str_replace(".pdf", "", $name);
>> $link= $row['content'];
>>
>> echo "<span class=\"pdflinks\">$name</span>";
>> echo "&nbsp;&nbsp;";
>> echo "<span class=\"sizes\">($size kb)</span>";
>> //<a href="#">ross</a>
>> ?>
>> download is here......
>> <a href="a-z.php?id=<?=$row['id'];?>">link</a> <br>

You need to make sure that the code above doesn't output anything when
isset($_GET['id']).

>> <?
>>
>> if(isset($_GET['id']))
>> {
>>  echo "id is this";

You should not have any output before you send your headers and file
content.

>> $id    = $_GET['id'];
>> $query = "SELECT * FROM publications WHERE id = '$id'";
>>
>> $result = mysql_query($query) or die('Error, query failed');
>>
>> $pdf_size=$row['pdf_size'];
>> $pdf_type=$row['pdf_type'];
>> $pdf_name=$row['pdf_name'];

Where does $row come from?

>> ob_clean();
>> header("Content-length: $pdf_size");
>> header("Content-type: $pdf_type");
>> header("Content-Disposition: attachment; filename=$pdf_name");
>> echo $content;

Where does $content come from?



-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.14.8/215 - Release Date: 2005/12/27
 

--- End Message ---
--- Begin Message ---
Hi,

I'm using the following code in a PHP 5.1, Windows CLI environment:

$p = new PDO('odbc:driver={Microsoft Access Driver (*.mdb)};Dbq=beispieldatenbank.mdb');
$s = $p->prepare('INSERT INTO ADDRESSES(TITLE0, LASTNAME0) VALUES(?, ?)');
$s->execute(array('test1', 'test2'));

I'm always getting the last value of the array passed to execute in all the fields which have markers in the prepare statement, like I would have written:

INSERT INTO ADDRESSES(TITLE0, LASTNAME0) VALUES('test2', 'test2')

I also tried bindValue like this

$s = $p->prepare('INSERT INTO ADDRESSES(TITLE0, LASTNAME0) VALUES(?, ?)');
$s->bindValue(1, 'test1');
$s->bindValue(2, 'test2');
$s->execute();

or name values:

$s = $p->prepare('INSERT INTO ADDRESSES(TITLE0, LASTNAME0) VALUES(:a, :b)');
$s->bindValue(':a', 'test1');
$s->bindValue(':b', 'test2');
$s->execute();

but which all resulted in a row being inserted but the values were just empty.

When I tried something like this:
$s = $p->prepare('INSERT INTO ADDRESSES(TITLE0, LASTNAME0) VALUES(?, ?)');
$val1 = 'test1';
$val2 = 'test2';
$s->bindParam(1, $val1);
$s->bindParam(2, $val2);
$s->execute();

I even get a crash.

Am I doing something conceptual wrong?

thanks for any pointers,
- Markus

--- End Message ---
--- Begin Message ---
This error happens in my Web http://www.millonarios.com.co/
 
Process limit exceeded for uid 10337 [25 >= 24]
 
as it can be the cause?
 
 
 
 

--- End Message ---
--- Begin Message ---
Hello,

Could you tell me a efficient solution for change page (new location) in
PHP? I tried this code : header("Location: mypage.php");

But in some case, I have error message "heade already send". Then I use a
javascript solution : window.location.href="mypage.php";

Is there a good solution in php ?

Thanks,

C.

___________________________________
Christian Ista
http://www.cista.be 

--- End Message ---
--- Begin Message ---
[snip]
Could you tell me a efficient solution for change page (new location) in
PHP? I tried this code : header("Location: mypage.php");

But in some case, I have error message "heade already send". Then I use a
javascript solution : window.location.href="mypage.php";

Is there a good solution in php ?
[/snip]

Header is a good solution, and is the only one available in PHP for
redirects. It requires that you do not send anything else out to the
browsers before sending the redirect, which is what is causing your error.
You can always use the output buffer functions to assist with that.

--- End Message ---
--- Begin Message ---
Christian Ista wrote:
> Hello,
> 
> Could you tell me a efficient solution for change page (new location) in
> PHP? I tried this code : header("Location: mypage.php");
> 
note:  HTTP/1.1 requires an absolute URI
http://php.net/header

> But in some case, I have error message "heade already send". Then I use a
> javascript solution : window.location.href="mypage.php";
> 
> Is there a good solution in php ?
> 

Check out 'headers_sent', you can choose how to redirect ('header' or
JavaScript) depending on whether you have sent the headers or not.

http://php.net/headers_sent

HTH, cheers
Silvio

-- 
tradeOver | http://www.tradeover.net
...ready to become the King of the World?

--- End Message ---
--- Begin Message ---
> From: Jay Blanchard [mailto:[EMAIL PROTECTED]
> Header is a good solution, and is the only one available in PHP for
> redirects. It requires that you do not send anything else out to the
> browsers before sending the redirect, which is what is causing your error.
> You can always use the output buffer functions to assist with that.

Ok but there is something more strange.

I use "header location" in a switch/case. An header location by case. I
don't understand at the end of the case, the header location don't work and
I go through the others cases.

Any idea why ?

Thanks,

--- End Message ---
--- Begin Message ---
Hi,

How do I install pdo_informix?

There's not much info on it's homepage http://pecl.php.net/package-changelog.php?package=PDO_INFORMIX and it's not yet in cvs php-src. Although it's in the root of cvs ( http://cvs.php.net/viewcvs.cgi/pecl/pdo_informix/ ).

I'd like to add it to the stable 5.1.1, but a newer version would do for testing.

Any ideas, with which version of php stable will pdo_informix be included?

Any other pdo informix related information appreciated.

Thanks!

--- End Message ---

Reply via email to