php-general Digest 9 Mar 2003 19:19:02 -0000 Issue 1928
Topics (messages 138838 through 138872):
Re: stripslashes()
138838 by: Leif K-Brooks
138864 by: John W. Holmes
A PHP UPDATE problem
138839 by: Terry Lau
138863 by: John W. Holmes
Re: save to file
138840 by: Niels Andersen
138845 by: Edwin Boersma
Re: no phun intended!!!
138841 by: Niels Andersen
138858 by: Richard Whitney
pagination help
138842 by: Denis L. Menezes
138846 by: Kevin Waterson
138866 by: David Eisenhart
Re: Php +Xml?
138843 by: Alexandru COSTIN
138844 by: Alexandru COSTIN
Re: variable string names
138847 by: Edwin Boersma
ob_start -- output buffer problem
138848 by: Alex Lance
receiving data elements from Access
138849 by: Jan Bro
Member function as error_handler
138850 by: Nik Makepeace
138867 by: David Eisenhart
138868 by: Nik Makepeace
138870 by: John W. Holmes
Syntax query
138851 by: Nik Makepeace
138869 by: Ernest E Vogelsinger
138871 by: Nik Makepeace
google-apis (was: error while reading google-search-results)
138852 by: Jens Lehmann
What am i doing wrong? SQL Query in PHP
138853 by: Rahul.Brenda
138854 by: Chris Hayes
138855 by: Rahul.Brenda
138856 by: - Edwin
138857 by: Chris Hayes
138859 by: chris
138860 by: Rahul.Brenda
138862 by: John W. Holmes
Re: What am i doing wrong? SQL Query in PHP [WORKS!!]
138861 by: Rahul.Brenda
Cleaning up HTML table structure
138865 by: Jens Lehmann
Form input security
138872 by: Chris Cook
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 ---
Try this (untestted):
if(get_magic_quotes_gpc()){
foreach($_REQUEST as $vname => $value){
$$vname = stripslashes($vname);
}
}
John Taylor-Johnston wrote:
I need to stripslashes() practically every $value as I pass data from one submit to another.
L\'apprentissage d\'une langue ...
Instead of doing it to every $value, someone showed me once something I could add something to the beginning of my script. It was some type of code on a post_var that turned off the addslashes on every $value. Anyone have an idea of what I'm talking about?
--
The above message is encrypted with double rot13 encoding. Any unauthorized attempt
to decrypt it will be prosecuted to the full extent of the law.
--- End Message ---
--- Begin Message ---
> I need to stripslashes() practically every $value as I pass data from
one
> submit to another.
>
> L\'apprentissage d\'une langue ...
>
> Instead of doing it to every $value, someone showed me once something
I
> could add something to the beginning of my script. It was some type of
> code on a post_var that turned off the addslashes on every $value.
Anyone
> have an idea of what I'm talking about?
Either turn off magic_quotes_gpc in php.ini or an .htaccess file or do
something like this:
Foreach($_GET as $key => $value)
{ $_GET[$key] = stripslashes($value); }
and the same for $_POST, etc.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--- End Message ---
--- Begin Message ---
Hello,
I am creating a polling system. Its operation likes this:
when the people vote the item, it updates the database by adding 1 for the
item automatically.
The part of code is showed here:
<?php
$colname_rsAddVote = "1";
if (isset($HTTP_POST_VARS['Vote'])) {
$colname_rsAddVote = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['Vote'] :
addslashes($HTTP_POST_VARS['Vote']);
}
mysql_select_db($database_cnTesting, $cnTesting);
$query_rsAddVote = "UPDATE Testing SET GetVotes = GetVotes + 1 WHERE VoteID
= %s", $colname_rsAddVote);
$rsAddVote = mysql_query($query_rsAddVote, $cnTesting) or
die(mysql_error());
?>
In fact, I use Dreamweaver MX to create the page.
But When I run the page, it shows an error. I don't how to reform it.
Thanks!!
Terry
_________________________________________________________________
今日星座 http://www.msn.com.hk/fortune/west/ 運程
--- End Message ---
--- Begin Message ---
> I am creating a polling system. Its operation likes this:
> when the people vote the item, it updates the database by adding 1 for
the
> item automatically.
> The part of code is showed here:
>
> <?php
> $colname_rsAddVote = "1";
> if (isset($HTTP_POST_VARS['Vote'])) {
> $colname_rsAddVote = (get_magic_quotes_gpc()) ?
$HTTP_POST_VARS['Vote'] :
> addslashes($HTTP_POST_VARS['Vote']);
> }
> mysql_select_db($database_cnTesting, $cnTesting);
> $query_rsAddVote = "UPDATE Testing SET GetVotes = GetVotes + 1 WHERE
> VoteID
> = %s", $colname_rsAddVote);
The above line is probably causing an error. You have
$var = "string", $var);
What are you trying to do?
> $rsAddVote = mysql_query($query_rsAddVote, $cnTesting) or
> die(mysql_error());
> ?>
> In fact, I use Dreamweaver MX to create the page.
> But When I run the page, it shows an error. I don't how to reform it.
WHAT'S THE ERROR? It helps us tremendously if you actually tell us what
the error is, what line it's on, and then show the relevant line with 5
or so lines before it also.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--- End Message ---
--- Begin Message ---
You want to add a new line every time your form is submittet, am I right?
Then you should open the file for appending, using fopen(filename, "a")
instead of "w"
"Ryan Holowaychuk" <[EMAIL PROTECTED]> wrote in message
news:!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAu5ugyx6+hUW5gsOu6grgVMKA
AAAQAAAAGYzyr/XD3kWb/[EMAIL PROTECTED]
> I am trying to save to a text file. And I have managed to do that part
> now, but what happens is when I save to the file, all the lines get put
> into one big line in the file.
>
> I am creating a roster input that I adding to our website: No, name
> grade .....
>
> The roster will contain 15 players
>
> So right now the implode puts everything on one line in the text file!!!
>
> So I am no sure if anybody can shed some light on this one.
>
> Thanks again
> Ryan
>
> <?
> //create a new file
> $fp = fopen("/place/on/server/" . $HTTP_POST_VARS['team'] , "w");
>
> $file_data = implode("\t\", $_POST);
> //this would return values spit by tabs
> //write to the open file handle
> fwrite($fp, $file_data . "\r\n");
> //close the file
> fclose($fp);
>
> ?>
>
>
>
>
>
--- End Message ---
--- Begin Message ---
Enough answers, I think? If you want EACH value of $_POST on a new line,
then why not implode with \n instead of \t?
Now you get only one big line, because you only WRITE one \n.
Edwin
Ryan Holowaychuk wrote:
I am trying to save to a text file. And I have managed to do that part
now, but what happens is when I save to the file, all the lines get put
into one big line in the file.
I am creating a roster input that I adding to our website: No, name
grade .....
The roster will contain 15 players
So right now the implode puts everything on one line in the text file!!!
So I am no sure if anybody can shed some light on this one.
Thanks again
Ryan
<?
//create a new file
$fp = fopen("/place/on/server/" . $HTTP_POST_VARS['team'] , "w");
$file_data = implode("\t\", $_POST);
//this would return values spit by tabs
//write to the open file handle
fwrite($fp, $file_data . "\r\n");
//close the file
fclose($fp);
?>
--- End Message ---
--- Begin Message ---
LOL
I like PHP, but I also like wet girlies. But the two are not interchangable,
which is a pitty, becouse sometimes I really could use a wet girl, and I
only have PHP....
"Khalid El-Kary" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> sorry, but if PHP (a great piece of knowledge) worths a wet girl for you,
so
> you don't know how to appreciate knowledge.
>
> "Both PHP and mod_perl are knowledge, science that's more honourful than a
> wet girl"
>
> Regards,
> Khalid Al-Kary
> http://creaturesx.ma.cx/kxparse/
>
> >http://www.fingers.co.za/arb/mod_perl.jpg
> >
> >If this starts a flame war, I'm going to be rather disappointed at people
> >that's not able to take a joke :P
> >
> >I think it's hilarious though...
> >
> >--
> >me
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> _________________________________________________________________
> MSN 8 with e-mail virus protection service: 2 months FREE*
> http://join.msn.com/?page=features/virus
>
--- End Message ---
--- Begin Message ---
BRAVO!!!
Quoting Niels Andersen <[EMAIL PROTECTED]>:
### LOL
###
### I like PHP, but I also like wet girlies. But the two are not
### interchangable,
### which is a pitty, becouse sometimes I really could use a wet girl, and I
### only have PHP....
###
###
###
### "Khalid El-Kary" <[EMAIL PROTECTED]> wrote in message
### news:[EMAIL PROTECTED]
### > sorry, but if PHP (a great piece of knowledge) worths a wet girl for
### you,
### so
### > you don't know how to appreciate knowledge.
### >
### > "Both PHP and mod_perl are knowledge, science that's more honourful than
### a
### > wet girl"
### >
### > Regards,
### > Khalid Al-Kary
### > http://creaturesx.ma.cx/kxparse/
### >
### > >http://www.fingers.co.za/arb/mod_perl.jpg
### > >
### > >If this starts a flame war, I'm going to be rather disappointed at
### people
### > >that's not able to take a joke :P
### > >
### > >I think it's hilarious though...
### > >
### > >--
### > >me
### > >
### > >
### > >--
### > >PHP General Mailing List (http://www.php.net/)
### > >To unsubscribe, visit: http://www.php.net/unsub.php
### >
### >
### > _________________________________________________________________
### > MSN 8 with e-mail virus protection service: 2 months FREE*
### > http://join.msn.com/?page=features/virus
### >
###
###
###
### --
### PHP General Mailing List (http://www.php.net/)
### To unsubscribe, visit: http://www.php.net/unsub.php
###
###
--
Richard Whitney *
Transcend Development
Producing the next phase of your internet presence.
[EMAIL PROTECTED] *
http://xend.net *
602-971-2791
* * *
* * *__ * *
_/ \___ *
* / * \* *
*/ * * \
* */\_ |\
/ \_ / \
/ \____/ \
/ \
/ \
/ \
--- End Message ---
--- Begin Message ---
Hello friends.
My records on one page are bout 200. So I wish to paginate them and show only about 20
records per page with the page numbers at the bottom of the records table and also the
"previous" and "next" links.
I mean, something line Google's searcg results page numbering system.
Can someone give me a link to some help files?
Thanks
Denis
--- End Message ---
--- Begin Message ---
This one time, at band camp,
"Denis L. Menezes" <[EMAIL PROTECTED]> wrote:
> Hello friends.
> Can someone give me a link to some help files?
http://www.phpbuilder.com/columns/rod20001214.php3
Kevin
--
______
(_____ \
_____) ) ____ ____ ____ ____
| ____/ / _ ) / _ | / ___) / _ )
| | ( (/ / ( ( | |( (___ ( (/ /
|_| \____) \_||_| \____) \____)
Kevin Waterson
Port Macquarie, Australia
--- End Message ---
--- Begin Message ---
This is a good article on pagination:
http://www.phpfreaks.com/tutorials/43/0.php
David Eisenhart
"Denis L. Menezes" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hello friends.
My records on one page are bout 200. So I wish to paginate them and show
only about 20 records per page with the page numbers at the bottom of the
records table and also the "previous" and "next" links.
I mean, something line Google's searcg results page numbering system.
Can someone give me a link to some help files?
Thanks
Denis
--- End Message ---
--- Begin Message ---
Hello,
DomXML is a large improvement over Sablot. If you take a close look at XML,
you'll see that XML is used effectively with some technologies : SAX (Simple
Api for XML), DOM (Document Object Modelling), XSL (Extensible styleshhet
language).
The DOMxml php extension (http://www.php.net/manual/en/ref.domxml.php) is a
wrapper for PHP usage of the libxml2 (xmlsoft.org) and libxslt1
(xmlsoft.org/XSLT) that helps you load XML files into DOM trees, manipulate
them using standard DOM API and transform them using XSL (with a blazing
speed, also).
You should compile your PHP version with DOM support (we have some RPMS
created for PHP with DOMXML support for Redhat 8.0, but they are not
released yet to the public as they are experimental).
I hope you have a better start now.
Alexandru
--
Alexandru COSTIN
Chief Operating Officer
http://www.interakt.ro/
+4021 411 2610
"Daniel" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> what is domxml ? is it similar to sablot ?
> >===== Original Message From "Alexandru COSTIN" <[EMAIL PROTECTED]>
=====
> > Hello,
> >
> >> Hello people,
> >>
> >> I want to start using Xml with php. How do I install xml on Apache with
> >Php?
> >> I am running redhat 7.2,Apache 1.3.12 and php latest version.
> > If you want to use SAX, you should already have it installed if you
have
> >compiled PHP with '--with-xml'. (BTW, have you compiled PHP yourself? -
do
> >you know how to compile PHP?).
> >
> > First of all you should upgrade to a newer apache, as as far as I
know
> >Apache 1.3.12 had some problem when ran with Sablotron (this would be
needed
> >if you will want to use XML with XSL transformations)
> >
> > Then you should use the domxml extension (add '--with-dom'
> >'--with-dom-xslt' '--with-dom-exslt' to your configure patch when you are
> >compiling PHP). After you compile PHP, you should have support for SAX,
DOM
> >and XSL transformations.
> >
> > And if you want a bootstrap to start using XMLs for content
publishing,
> >you should also look at Krysalis at
> >http://www.interakt.ro/products/Krysalis/
> >
> > Alexandru
> >
> >>
> >> How do I install xml? I am totally new to Xml....and want to start
> >> somewhere...
> >>
> >> -Dhaval
> >>
> >>
> >>
> >>
> >>
> >> _________________________________________________________________
> >> MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
> >> http://join.msn.com/?page=features/virus
> >>
> >
> >
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Hello James,
Your vision is very similar to ours.
You should take the Krysalis platform (LGPL) and give it a try. It's a
mature solution (similar to cocoon) for XML/XSL publishing, and allows you
to define the way requests are served, define the way dynamic XML trees are
created and then define how to add the presentation layer to them.
Alexandru
--
Alexandru COSTIN
Chief Operating Officer
http://www.interakt.ro/
+4021 411 2610
"James" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> There are distinct differences to parsing XML into your program and
> producing XML from your program.
>
> We use the following method's which are enabling us to create scalable
> systems with independent design from code.
> One of the clear reasons for using XML/XSLT is the seperation of data and
> design. If you imagine that your ecommerce application is working very
well
> and doesnt need changing but you have a new client who wants the system in
> thier design. Usually, there will come a point where you have to change
> hardcoded design elements within your ecommerce application - and if the
> design is radically different you will need to do conditional statements
to
> determine which design to use - a real pain. More importantly your
playing
> with your engine (code) when in fact all you really wanted to do was put
on
> some new alloys! :-) It's boring, time consuming and often results in
*****
> up code.
>
> If you take the XML and XSLT path you instantly change your method. Your
> ecommerce application only EVER spews out XML. That's it's purpose in
> life - it has it's business rules and it's resulting output and design is
> never a factor. The XSLT style sheets are used to implement the XML into
a
> valid document usable by humans. In essence you can now have a 1000
> independent designs which never require a single code change in your main
> commerce app. Taking it further you can employ your xsl sheets to spew
out
> WML, CSV, XML etc etc. Simply, your have reached a true data and design
> independence.
>
> Added to this you can offer third parties an industry standard form of
data
> exchange. You can use multiple languages and know with confidence that
none
> of them have to understand each other. We are using this method very
> shortly to create a win32 application using the XML feed from our commerce
> engine. Eventually it will be used by our customer service team.
>
> >php are
> > insanely tedious to replicate in xsl :|
> >
>
> I totally disagree. Take the following:
>
> for ($i=0;$i<=10;$i++){
> echo "<tr><td>Hello</td></tr>";
> }
>
>
> Take the following in XSLT:
>
> <xsl:for-each select="node/to/match">
> <tr><td><xsl:value-of select="." /></td></tr>
> </xsl:for-each>
>
> They may be about the same in number of lines but the php app must be
> modified to create a different table type. It is true however that unless
> you need to something on a large scale these methods may be to much.
>
>
> James.
>
>
>
>
>
>
>
> "Daniel" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > wot exactly does the xml parse do over sablot ? and what benfit do u get
> > xml'ing an entire site , where some processes which come easy to do in
php
> are
> > insanely tedious to replicate in xsl :|
> >
> > >===== Original Message From "James" <[EMAIL PROTECTED]> =====
> > >There is nothing to install.
> > >
> > >By default php usually comes with XML parser methods - however if you
> want
> > >to invest time in running XSLT/XPATH styles against XML you need to
> install
> > >server side software such as Sablotron or Saxon. We run Sablotron and
> it's
> > >very good. We've also invested in Stylus Studio which is a good
xml/xslt
> > >development tool.
> > >
> > >I'm not really sure what you want to do so it's difficult to help you
> > >further. If you give a small idea of what it is you want to achieve
> then
> > >it might be easier to help you on your way.
> > >
> > >Jim.
> > >
> > >
> > >"Dhaval Desai" <[EMAIL PROTECTED]> wrote in message
> > >news:[EMAIL PROTECTED]
> > >> Hello people,
> > >>
> > >> I want to start using Xml with php. How do I install xml on Apache
with
> > >Php?
> > >> I am running redhat 7.2,Apache 1.3.12 and php latest version.
> > >>
> > >> How do I install xml? I am totally new to Xml....and want to start
> > >> somewhere...
> > >>
> > >> -Dhaval
> > >>
> > >>
> > >>
> > >>
> > >>
> > >> _________________________________________________________________
> > >> MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
> > >> http://join.msn.com/?page=features/virus
> > >>
> > >
> > >
> > >
> > >--
> > >PHP General Mailing List (http://www.php.net/)
> > >To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
--- End Message ---
--- Begin Message ---
John's solution is the better one. But if you really wish to stick to
your own, try and use eval() to complile $where$i.
Edwin
John W. Holmes wrote:
I have:
if ($where1 != '')
{
$whereArray = array_push($whereArray, $where1);
}
and I want to repeat for $where1 up to $where8
but rather than write it out 8 times, I'd rather use a loop
for ($i=1; $i<=8 i++)
{
if ($where1 != '')
{
$whereArray = array_push($whereArray, $where1);
}
}
but how can I change $where1 to $where2, $where3 etc using $i.
nothing I try seems to work. Do I use eval?
Yes, you can use variable variables, like others have suggested, but why
not just use an array? Almost every implementation of variable-variables
seems to be a work around that's used instead of arrays.
Where are all of your $where variables coming from? If they are from a
form, just name them as "where[]", then simply loop through them using
foreach($_POST['where']) and check them all. This makes your code more
dynamic as you can add/subtract "where[]" elements and your "processing"
code doesn't change. With a variable-variable solution, you have to
change the number of loops you run each time to change the number of
"where" elements you have.
---John Holmes...
--- End Message ---
--- Begin Message ---
Hi all,
to quote from http://www.php.net/manual/en/function.ob-start.php
> void ob_start ( [string output_callback])
>
> An optional output_callback function may be specified. This function
> takes a string as a parameter and should return a string. The function
> will be called when ob_end_flush() is called, or when the output
> buffer is flushed to the browser at the end of the request.
My callback function does not get called unless I manually call
ob_end_flush().
I'm not interested in calling ob_end_flush() at all, I want my callback
function to be called "when the output buffer is flushed to the browser
at the end of the request" so the question is why isn't this happening?
here's my example:
<?php
$x = new test();
echo "hey";
// IF next line is uncommented so it manually flushes
// then the finish method WILL get called. But I need
// get around calling anything at the *end* of a script.
//ob_end_flush();
class test {
var $msg_file = "cooked_html/error_log2";
function test() {
ob_start(array(&$this, "finish"));
$this->msg("got to initialize");
}
function finish($page) {
$this->msg("GOT TO FINISH!!!");
return $page;
}
function msg ($msg) {
$msg = "\n" . exec("date") ." ::: ". $msg;
$fp = fopen($this->msg_file, "a") or die ("cannot open ".$this->msg_file);
fputs ($fp, $msg, strlen($msg)) or die ("cannot write to ".$this->msg_file);
fclose($fp);
}
}
?>
But if ob_end_flush() IS called then the error log WILL have the "GOT TO
FINISH" message.
Any ideas on why the output is not being flushed automatically?
thanks
Alex
--- End Message ---
--- Begin Message ---
I've got the following code:
$datum_beginn="2002-12-12";
$datensatz=odbc_exec($db_connection,"select * from Termin where Datumsfeld
>'#$datum_beginn#'");
I get an error message that data in creteria doesn't match. (free
translation)
The error def. lays in Datumsfeld >'#$datum_beginn#'. How do I get a list of
all entries with a
date that lay behind a certain date? I'd prefer to let the database do the
job for me, rather than
pulling everything out and get the relevant data with php.
thx
Jan
--- End Message ---
--- Begin Message ---
Query One: Can I use a member function of an object as an error_handler?
I currently declare a function for error handling with every page, but I
would like to put it in an object which lives in the session anyway. The
problem is I can't seem to do it; when I try to set the error handler to
a method, it defaults to PHP's usual methods. Is it me or PHP?
MTIA,
Nik
--
http://travelog.uberblog.com/
--- End Message ---
--- Begin Message ---
I'd recommend that you consider using the set_error_handler function.
This'll let you create and use your own custom error handler function (which
is fired for errors of the E_ERROR, E_WARNING and E_NOTICE type and also
those errors that you deliberately trigger using trigger_error()) - very
handy indeed!
Of course rather than doing this on every page place such code in a single
file and include this file (using the include construct or variation on
this) within all your site pages.
Hope this helps.
David Eisenhart
"Nik Makepeace" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Query One: Can I use a member function of an object as an error_handler?
>
> I currently declare a function for error handling with every page, but I
> would like to put it in an object which lives in the session anyway. The
> problem is I can't seem to do it; when I try to set the error handler to
> a method, it defaults to PHP's usual methods. Is it me or PHP?
>
> MTIA,
> Nik
> --
> http://travelog.uberblog.com/
>
--- End Message ---
--- Begin Message ---
On Mon, 2003-03-10 at 02:40, David Eisenhart wrote:
> I'd recommend that you consider using the set_error_handler function
Of course, this is what I am doing. My question is can I use a member
function of an object as an error handler? I don't seem to be able to,
but I might have overlooked something.
Nik
--- End Message ---
--- Begin Message ---
> > I'd recommend that you consider using the set_error_handler function
>
> Of course, this is what I am doing. My question is can I use a member
> function of an object as an error handler? I don't seem to be able to,
> but I might have overlooked something.
Read the user notes on the manual page, there are a few suggestions on
how you can do this.
http://www.php.net/manual/en/function.set-error-handler.php
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--- End Message ---
--- Begin Message ---
Can anyone tell me why this doesn't work:
$db_object = pg_fetch_object($this->getLastResult());
In imaginary interactive mode, it works like this:
ME > echo $this->getLastResult();
PHP> Resource id #67
ME > echo $this->mr_lastResult;
PHP> Resource id #67
ME > echo pg_fetch_object($this->getLastResult());
PHP>
ME > echo pg_fetch_object($this->mr_lastResult);
PHP>
Any ideas?
Nik
--
http://travelog.uberblog.com/
--- End Message ---
--- Begin Message ---
At 13:38 09.03.2003, Nik Makepeace said:
--------------------[snip]--------------------
>Can anyone tell me why this doesn't work:
>
>$db_object = pg_fetch_object($this->getLastResult());
>
>In imaginary interactive mode, it works like this:
>
>ME > echo $this->getLastResult();
>PHP> Resource id #67
>ME > echo $this->mr_lastResult;
>PHP> Resource id #67
>ME > echo pg_fetch_object($this->getLastResult());
>PHP>
>ME > echo pg_fetch_object($this->mr_lastResult);
>PHP>
>
>Any ideas?
--------------------[snip]--------------------
From the docs:
pg_fetch_object() returns an object with properties that correspond to the
fetched row. It returns FALSE if there are no more rows or error.
The behaviour of your code is expected if you looped either past the
returned records, or there are no records returned by the previous query.
--
>O Ernest E. Vogelsinger
(\) ICQ #13394035
^ http://www.vogelsinger.at/
--- End Message ---
--- Begin Message ---
On Mon, 2003-03-10 at 03:01, Ernest E Vogelsinger wrote:
> At 13:38 09.03.2003, Nik Makepeace said:
> --------------------[snip]--------------------
> >Can anyone tell me why this doesn't work:
> >
> >$db_object = pg_fetch_object($this->getLastResult());
>
> pg_fetch_object() returns an object with properties that correspond to the
> fetched row. It returns FALSE if there are no more rows or error.
Yes, the error was indeed between the chair and keyboard. In fact I had
(while curious) lazily wrapped all queries in "begin" and "commit" and
this was causing the problem - the last result was the result of the
commit, not the select.
Thanks anyway.
Nik
--- End Message ---
--- Begin Message ---
James wrote:
LWP is a perl thing. Curl is probably the best thing to use.
Have you tried using googles php api which they provide free?
http://www.google.com/apis/
I had a look at the API, but I'm not sure if it's appropriate and easy
to use with PHP. It's still beta and might change again (or maybe I've
to pay for every query soon). Has anyone already used the api? Is it
simple to (for instance) find out all listed pages of www.foo.com which
are in the Top 1000?
Jens
--- End Message ---
--- Begin Message ---
I want to display the first 3 words of my record in
the my table and following is the code i'm using.
When i use the SQL Query in mySQL.. it works great..
but when i try to implement it in my php page.. i'm
not getting anything.. no error, no display, no
result.. just blank.. why?
<?php
$db = mysql_connect("localhost","user","pass");
mysql_select_db("mydb",$db);
$result = mysql_query("SELECT substring_index(title, '
', 3) from news order by ID desc limit 4",$db);
if ($myrow = mysql_fetch_array($result)) {
do {
echo(" $myrow[title] ");
} while ($myrow = mysql_fetch_array($result));
}
?>
Rahul S. Johari
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
--- End Message ---
--- Begin Message ---
At 13:37 9-3-2003, you wrote:
I want to display the first 3 words of my record in
the my table and following is the code i'm using.
When i use the SQL Query in mySQL.. it works great..
but when i try to implement it in my php page.. i'm
not getting anything.. no error, no display, no
result.. just blank.. why?
i don't know what's wrog but you could do some quick debugging
by echoing mysql_error() when the query fails.
($result=mysql_query(.....) or die ('<br>Query failed at'.__FILE__.' line
'.__LINE__.' and mysql says:<br>'.mysql_error());
<?php
$db = mysql_connect("localhost","user","pass");
mysql_select_db("mydb",$db);
$result = mysql_query("SELECT substring_index(title, '
', 3) from news order by ID desc limit 4",$db);
if ($myrow = mysql_fetch_array($result)) {
do {
check whether there are some results walked through by doing something
silly like echo '*'; here.
echo(" $myrow[title] ");
} while ($myrow = mysql_fetch_array($result));
}
?>
--- End Message ---
--- Begin Message ---
Ok i tried this.. and i didn't get any error listed..
so it seems that the mySQL Query is not failing in
syntax or logic.. but it's not picking up any rows.
Which is really stupid because i used my phpmyadmin
and i ran this SQL Query there and even then i got my
results..
--- Chris Hayes <[EMAIL PROTECTED]> wrote:
> At 13:37 9-3-2003, you wrote:
> >I want to display the first 3 words of my record in
> >the my table and following is the code i'm using.
> >When i use the SQL Query in mySQL.. it works
> great..
> >but when i try to implement it in my php page.. i'm
> >not getting anything.. no error, no display, no
> >result.. just blank.. why?
>
> i don't know what's wrog but you could do some quick
> debugging
> by echoing mysql_error() when the query fails.
> ($result=mysql_query(.....) or die ('<br>Query
> failed at'.__FILE__.' line
> '.__LINE__.' and mysql says:<br>'.mysql_error());
>
> ><?php
> >
> >$db = mysql_connect("localhost","user","pass");
> >mysql_select_db("mydb",$db);
> >
> >$result = mysql_query("SELECT
> substring_index(title, '
> >', 3) from news order by ID desc limit 4",$db);
> >if ($myrow = mysql_fetch_array($result)) {
> > do {
> check whether there are some results walked through
> by doing something
> silly like echo '*'; here.
>
>
> > echo(" $myrow[title] ");
> > } while ($myrow = mysql_fetch_array($result));
> >}
> >?>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
--- End Message ---
--- Begin Message ---
Hello,
"Rahul.Brenda" <[EMAIL PROTECTED]> wrote:
> Ok i tried this.. and i didn't get any error listed..
> so it seems that the mySQL Query is not failing in
> syntax or logic.. but it's not picking up any rows.
> Which is really stupid because i used my phpmyadmin
> and i ran this SQL Query there and even then i got my
> results..
So, you still have a "blank" page? Check the resulting html source code
and see how it looks like. Also, do you have "display_errors = On" in
your php.ini?
Btw, see if changing this:
> > > echo(" $myrow[title] ");
to this:
echo $myrow["title"];
makes any difference.
Just my 2 cents...
- E
__________________________________________________
Do You Yahoo!?
Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/
--- End Message ---
--- Begin Message ---
At 13:37 9-3-2003, you wrote:
if ($myrow = mysql_fetch_array($result)) {
do {
echo(" $myrow[title] ");
} while ($myrow = mysql_fetch_array($result));
}
PS same result with
while ($myrow = mysql_fetch_array($result));
{ echo $myrow['title'];
}
--- End Message ---
--- Begin Message ---
On Sun, 9 Mar 2003 04:37:47 -0800 (PST), Rahul.Brenda
<[EMAIL PROTECTED]> wrote:
I want to display the first 3 words of my record in
the my table and following is the code i'm using. When i use the SQL
Query in mySQL.. it works great..
but when i try to implement it in my php page.. i'm
not getting anything.. no error, no display, no
result.. just blank.. why?
<?php
$db = mysql_connect("localhost","user","pass");
mysql_select_db("mydb",$db);
$result = mysql_query("SELECT substring_index(title, '
', 3) from news order by ID desc limit 4",$db);
if ($myrow = mysql_fetch_array($result)) {
do {
echo(" $myrow[title] ");
} while ($myrow = mysql_fetch_array($result));
}
?>
Rahul S. Johari
Why not do it like this?
// fetch row is faster than fetch_assoc, which is faster than fetch_array
// fetch_result might even be a better choice here, though, with only one
item...
if (!mysql_num_rows($result)) {
print 'no results';
} else {
while (list($title) = mysql_fetch_row($result)) {
print $title; // don't quote variables if you only want to print them by
themselves
}
}
--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
--- End Message ---
--- Begin Message ---
Hi,
> So, you still have a "blank" page?
Yes i do actually, and blank in HTML Source too.
> do you have "display_errors = On" in your php.ini?
Ahan.. yes i do.
> to this:
>
> echo $myrow["title"];
>
> makes any difference.
No actually it didnt. :0(
Rahul S. Johari
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
--- End Message ---
--- Begin Message ---
> I want to display the first 3 words of my record in
> the my table and following is the code i'm using.
> When i use the SQL Query in mySQL.. it works great..
> but when i try to implement it in my php page.. i'm
> not getting anything.. no error, no display, no
> result.. just blank.. why?
>
> <?php
>
> $db = mysql_connect("localhost","user","pass");
> mysql_select_db("mydb",$db);
>
> $result = mysql_query("SELECT substring_index(title, '
> ', 3) from news order by ID desc limit 4",$db);
> if ($myrow = mysql_fetch_array($result)) {
> do {
> echo(" $myrow[title] ");
> } while ($myrow = mysql_fetch_array($result));
> }
> ?>
In case you're wondering, your method is fine. You can continue to use
this or what chris suggested. Either way, the problem is that you need
an alias for your column that you selected. With the above code, you
didn't select a column called "title" so you can't use $row['title'].
You created a column called "substring_index(title, ' ', 3)" so you'll
have to use $row["substring_index(title, ' ', 3)"]. As you can probably
guess, there's an easier way to do it, though...
If you use a query such as:
SELECT SUBSTRING_INDEX(title, ' ', 3) AS f_title FROM news ORDER BY id
LIMIT 4
You can then use $row['f_title'] to print the result. Using "AS" in your
query will rename the column to "f_title" or whatever you put there.
This is called assigning the column an alias.
Of course, though all of this you could of just used $row[0] to get the
value. I tend to stay away from using numerical indexes though, as it
makes it harder for other people to follow your code. When you see
$row['f_title'], it gives you a good idea of what you're displaying.
When you see $row[0], you have no idea what it is and you have to go
find the query that was run in order to determine what column zero was.
Hope that helps.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/
--- End Message ---
--- Begin Message ---
Chris,
Thanks a lot.. THIS WORKS!
Works brilliantly. All other methods were just
failing. Thanks man.
> // fetch row is faster than fetch_assoc, which is
> faster than fetch_array
> // fetch_result might even be a better choice here,
> though, with only one
> item...
> if (!mysql_num_rows($result)) {
> print 'no results';
> } else {
> while (list($title) = mysql_fetch_row($result)) {
> print $title; // don't quote variables if you only
> want to print them by
> themselves
> }
> }
Rahul S. Johari
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/
--- End Message ---
--- Begin Message ---
The following problem seems to be hard to solve:
A PHP-Script reads in an HTML-File and removes linebreaks, tabs and not
needed spaces. After that the script should reconstruct the
table-structure this way (example):
<table ... >
<tr ... >
<td ... >
<table ...>
<tr ... >
<td ... >
...
</td>
<td ... >
...
</td>
</tr>
</table>
</td>
</tr>
</table>
The next thing is that lines longer than for instance 80 chars
($maxlength) should be split up into several lines.
Is there any good way to solve this? Regular expressions seem to be of
limited use because the recursion of tables can be infinitely deep and
the lines between <td and </td> must not not be longer than $maxlength
and should have the appropriate number of spaces before it. Stepping
through the string (the whole file is a string) with simple
String-functions is very complicated either.
I hope you can give me some hints how to find a (simple) solution for
this problem.
Jens
--- End Message ---
--- Begin Message ---
Hello all,
When using forms, when do I have to worry about cleaning up user data? I
know to use escapeshellarg() when using system functions, but how about when
using the user data for database inserts? Also, if I do not insert the data
into the database or use any system commands, do I still need to clean the
data?
Thanks,
Chris
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail
--- End Message ---