php-general Digest 13 Jan 2002 07:34:05 -0000 Issue 1108
Topics (messages 80300 through 80334):
mysql_fetch_row win32 to Linux
80300 by: sundogcurt
80312 by: mike cullerton
Is DOMXML reliable??
80301 by: Emile Bosch
help with include
80302 by: Brian's News
80304 by: sundogcurt
80332 by: Mehmet Kamil ERISEN
Re: Development environment
80303 by: Rafael Perazzo
80326 by: Zeev Suraski
Event based applications?
80305 by: Morten Nielsen
80306 by: Andrew Brampton
80307 by: Matt Friedman
Record Paging Using Arrays
80308 by: Joe Van Meer
form get method
80309 by: Gerard Samuel
Re: preg_replace help
80310 by: Boaz Yahav
80333 by: Gaylen Fraley
Re: multiple replaces...
80311 by: Paul Roberts
80313 by: Dennis Moore
80318 by: Rambo Amadeus
Please "\n" problem????
80314 by: Dani
80315 by: Gianluca Baldo
80316 by: Dennis Moore
Re: continue [PHP] Please "\n" problem????
80317 by: Dani
80319 by: Thomas Holton
Print ONCE ONLY?????
80320 by: Dani
80321 by: Michael Kimsal
80322 by: Dennis Moore
80323 by: Michael Kimsal
80324 by: Pavel Kharitonov
Thanks! Re: [PHP] Print ONCE ONLY?????
80325 by: Dani
Piping data into a select box
80327 by: Dean Householder
80330 by: hugh danaher
80334 by: Jimmy
Time Zone Offset?
80328 by: Marvin Sanders
form values and the back button
80329 by: Alastair
Re: HTTP Server vars
80331 by: Alastair
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 everybody, I have some scripts running on win32 Apache mySQL and they
all run great. I have copied the entire application to my Linux box
which I think I have running pretty smoothly now. The database is there
and I can access it just fine etc etc.
Here is the hitch (there's always a hitch) I can't get PHP to retrieve
my data after a SELECT query. I know the query works simply by setting
and displaying flags. It seems to choke on mysql_fetch_row. Here is an
example.
Here is a snippet I have written
$myquery = "SELECT * FROM xpackage";
print "<p>myquery = $myquery</p>";
$myresult = mysql_query($myquery);
while($myrowz = mysql_fetch_row($myresult)){
print "<p>" . $myrowz[0] . "</p>";
}
On the win32 box (identical snippet and identical db on both machines)
I get this back
myquery = SELECT * FROM xpackage
62
61
60
59
58
57
56
55
54
53
115
114
127
126
111
125
On the Linux box I get this
myquery = SELECT * FROM xpackage
Warning: Supplied argument is not a valid MySQL result resource in /path
to page with error/default.php on line 5
Line 5 is this part
while($myrowz = mysql_fetch_row($myresult)){
I am at a total loss, I have not seen anywhere stating that
mysql_fetch_row is depreciated, does anybody have anything to add to
this to help me out?
--- End Message ---
--- Begin Message ---
on 1/12/02 11:45 AM, sundogcurt at [EMAIL PROTECTED] wrote:
> myquery = SELECT * FROM xpackage
> Warning: Supplied argument is not a valid MySQL result resource in /path
> to page with error/default.php on line 5
>
> Line 5 is this part
> while($myrowz = mysql_fetch_row($myresult)){
this tells me that $myresult is not a valid mysql result resource
identifier. how do you obtain $myresult?
-- mike cullerton
--- End Message ---
--- Begin Message ---
Hi list,
It seems like domxml is kinda unreliable to build an CMS with because
in lotta versions the syntax is different :(
Is DOMXML reliable??
Or should i use an alternative, does anyone know an
alternative??
Warm regards,
Emile Bosch
--- End Message ---
--- Begin Message ---
Hi, I need some help with the include function.
I have a phpBB script and want to put the config.inc.php file in a password
protected directory, Easy peasy you might say, and I know it is, but the
problem comes because the password protected directory isn't on the site the
script is on, mainly because the host says I've got to upgrade my account to
use password protected dir's.
I've got one site with a password protected dir available and would like to
put it on there.
Any idea's how to do it would be appreciated.
Many thanks
Brian
--- End Message ---
--- Begin Message ---
I think you can use a URL when you specify your value in the include
statement, can you not?
[EMAIL PROTECTED] wrote:
>Hi, I need some help with the include function.
>I have a phpBB script and want to put the config.inc.php file in a password
>protected directory, Easy peasy you might say, and I know it is, but the
>problem comes because the password protected directory isn't on the site the
>script is on, mainly because the host says I've got to upgrade my account to
>use password protected dir's.
>I've got one site with a password protected dir available and would like to
>put it on there.
>
>Any idea's how to do it would be appreciated.
>
>Many thanks
>
>Brian
>
>
>
--- End Message ---
--- Begin Message ---
I have installed phpBB several times. Your problem should
not be the password protected directory.
The install.php script tries to wright into the config
file.
so, you have to chmod your file and give r/w access to
everybody.
once insallation is completed, then change it the was it
was originally.
if you give me the url, i can better understand your
problem.
erisen
--- Brian's News <[EMAIL PROTECTED]> wrote:
> Hi, I need some help with the include function.
> I have a phpBB script and want to put the config.inc.php
> file in a password
> protected directory, Easy peasy you might say, and I know
> it is, but the
> problem comes because the password protected directory
> isn't on the site the
> script is on, mainly because the host says I've got to
> upgrade my account to
> use password protected dir's.
> I've got one site with a password protected dir available
> and would like to
> put it on there.
>
> Any idea's how to do it would be appreciated.
>
> Many thanks
>
> Brian
>
>
>
> --
> 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]
>
=====
Mehmet Erisen
http://www.erisen.com
__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
--- End Message ---
--- Begin Message ---
I know two good IDEs for PHP:
PhpEdit -> http://www.phpedit.com
PhpCode -> http://www.phpide.de
Have fun!!
Rafael Perazzo
--- Morten Nielsen <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Can anybody recommend a good development
> environment? It should support PHP,
> HTML and JavaScripts.
> Another question...Is it normal procedure to mix the
> above 3 languages on a
> single page or is it possible to only use 1...i.e
> PHP?
>
> Regards,
> Morten
__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
--- End Message ---
--- Begin Message ---
At 06:00 PM 1/12/2002, Morten Nielsen wrote:
>Hi,
>
>Can anybody recommend a good development environment? It should support PHP,
>HTML and JavaScripts.
http://www.zend.com/store/beta.php - it doesn't have any special JavaScript
support, but it's by far the strongest one for PHP itself.
Zeev
--- End Message ---
--- Begin Message ---
Hi,
I am about to make an homepage. It is going to be very event based. When the
user presses different buttons different functions should be called.
At the same time I am going to use a database to store some data.
My question is: Should I use PHP or JavaScripts?
I would like to have a server based page, but PHP doesn't support the event
driven methods like JavaScripts.
Please send your comments,
Morten
--- End Message ---
--- Begin Message ---
How do you plan to place stuff in a database without using a "Server based
page"?
I think you will need to use a combination of the 2. Make the JScript call
PHP pages to do the handling of your events.
Andrew
----- Original Message -----
From: "Morten Nielsen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 12, 2002 7:36 PM
Subject: [PHP] Event based applications?
> Hi,
>
> I am about to make an homepage. It is going to be very event based. When
the
> user presses different buttons different functions should be called.
> At the same time I am going to use a database to store some data.
> My question is: Should I use PHP or JavaScripts?
> I would like to have a server based page, but PHP doesn't support the
event
> driven methods like JavaScripts.
>
> Please send your comments,
> Morten
>
>
>
> --
> 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]
>
>
--- End Message ---
--- Begin Message ---
JavaScript runs on the client, PHP runs at the server. PHP cannot access
client side events directly.
JavaScript cannot access the database (actually it can through Internet
Explorer, but that's different story...)
You'll use a combo of both languages.
Matt Friedman
Web Applications Developer
www.SpryNewMedia.com
Email: [EMAIL PROTECTED]
-----Original Message-----
From: Morten Nielsen [mailto:[EMAIL PROTECTED]]
Sent: Saturday January 12, 2002 1:37 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Event based applications?
Hi,
I am about to make an homepage. It is going to be very event based. When
the
user presses different buttons different functions should be called.
At the same time I am going to use a database to store some data.
My question is: Should I use PHP or JavaScripts?
I would like to have a server based page, but PHP doesn't support the
event
driven methods like JavaScripts.
Please send your comments,
Morten
--
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]
--- End Message ---
--- Begin Message ---
Hi there, I have a small php/data driven website and would like to
incorporate record paing. Unfortunately I'm working with sql Server
temporarily, but I'm still required to do this. So since I wasn't allowed to
use the handy LIMIT in my sql statement I figured I'd dump my results into a
mulitdiensional array and navigate through the records that way. I know this
propbabbly isn't the best method, but it's the way I have to do it for now.
I've managed to display my records out of the array, but would now like to
incorporate a "next' and a 'previous' button to navigate through the array.
Can someone take a look at my code below and tell me how I'm to go about
doing this? I thought maybe by having 2 functions that would advance my
array pointer and another to retreat the pointer would do the trick. I'm
unsure how to incorporate it. I've added two functions within the
************ below, not sure if they are appropriate or not though.
Thx Joe :)
Code:
if(!isset($consultantarray)){
//connect to db
$connectionToDB = odbc_connect("cdxcffcoltant", "jo7gecon", "josje7con");
//create query statement
$sqls = "SELECT consultantid, firstname, lastname, city, stateprovince,
country, category, yearsexp FROM CONSULTANT WHERE category ='$category'
ORDER BY yearsexp DESC" ;
//execute the sql statement (query) on the connection made
$resultset = odbc_do($connectionToDB, $sqls);
//initialize the consultant arrays
$consultantdetailsarray[] = array();
$consultantarray[] = array();
//initialize a variable to zero for start of array below in while loop
$x = 0;
// while there is still results fetch the data from the database --- while
loop
while(odbc_fetch_row($resultset)){
$consultantdetailsarray[0] = odbc_result($resultset, 1);
$consultantdetailsarray[1] = odbc_result($resultset, 2);
$consultantdetailsarray[2] = odbc_result($resultset, 3);
$consultantdetailsarray[3] = odbc_result($resultset, 4);
$consultantdetailsarray[4] = odbc_result($resultset, 5);
$consultantdetailsarray[5] = odbc_result($resultset, 6);
$consultantdetailsarray[6] = odbc_result($resultset, 7);
$consultantdetailsarray[7] = odbc_result($resultset, 8);
//dump each consultant into the new array called $consultantarray
$consultantarray[$x] = $consultantdetailsarray;
//increment to next element of array
$x++;
}
}
****************************************************************************
*
function nextFive(&$array, $number){
for ($counter = 0; $counter < $number; $counter++){
next($array);
}
}
function previousFive(&$array, $number){
for ($counter = 0; $counter < $number; $counter++){
prev($array);
}
}
****************************************************************************
*
//loop through the elements of retrieved array (2nd one holding the
consultant details)
//second loop to grab through $consultant details array elements
foreach($consultantarray as $y){
list($cid, $firstname, $lastname, $city, $stateprovince, $country,
$category, $yearsexp) = $y;
print "<tr><td align=left><font color='#663399' face='verdana' size=2><a
href='consultantdetails.php?cid=" . $cid . "'>" . $firstname . " " .
$lastname . "</a></font></td><td align=left><font color='#663399'
face='verdana' size=2>" . $city . "</font></td><td align=left><font
color='#663399' face='verdana' size=2>" . $stateprovince . "</font></td><td
align=left><font color='#663399' face='verdana' size=2>" . $country .
"</font></td><td align=left><font color='#663399' face='verdana' size=2>" .
$category . "</font></td><td align=left><font color='#663399' face='verdana'
size=2>" . $yearsexp . "</font></td></tr>";
}
--- End Message ---
--- Begin Message ---
Hey all. I was making a menu, and I was using too many links, so I
figure use a form with drop down lists.
Im trying to use the form using the get method.
echo '<form action="test.php?ft=first" method="get">';
It doesn't seem to behave correctly. Can one use test.php?ft=first in
the action of a get form??
It works great if I make a hidden field for ft=first.
Was just wondering..
--- End Message ---
--- Begin Message ---
Here are some scripts to help you :
http://www.weberdev.com/index.php3?GoTo=get_example.php3?count=1235
http://www.weberdev.com/index.php3?GoTo=get_example.php3?count=1234
http://www.weberdev.com/index.php3?GoTo=get_example.php3?count=1401
http://www.weberdev.com/index.php3?GoTo=get_example.php3?count=1403
Sincerely
berber
Visit http://www.weberdev.com Today!!!
To see where PHP might take you tomorrow.
-----Original Message-----
From: Gaylen Fraley [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 12, 2002 5:20 AM
To: [EMAIL PROTECTED]
Subject: [PHP] preg_replace help
I have need to be able to replace text within a string to turn it into a
link. In other words, I might have a phrase lik:
"blah, blah, blah, please visit my site at www.mysite.com. blah,
blah,blah".
I need to have the string converted to "blah, blah, blah, please visit
my
site at http://www.mysite.com. blah, blah,blah". The link might have
more
than 3 sections and won't necessarily end in .com (.net,.com.nl, etc.).
Here is what I have been testing (then I get stuck):
$myLink = "Please visit my web site at www.mysite.com. You will be glad
you
did!";
$repLink = preg_replace("/(www.)/i","<a href=http://\\1",$myLink);
which yields
Please visit my web site at <a href=http://www.mysite.com. You will be
glad
you did!
What I would need is
Please visit my web site at <a
href=http://www.mysite.com>www.mysite.com</a>. You will be glad you did!
To be truthful, pattern matching is giving me migraines! Programming
has
always been natural to me (32 years of it), but this challenge (eregi,
preg_match,etc.) is making me crazy! Can someone recommend a good
tutorial
or book on this subject?
Thanks!
--
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]
--- End Message ---
--- Begin Message ---
First of all, thanks to everyone who replied! I have several good
suggestions. Here is one that seems to work pretty well, to cover a
multitude of situations:
$msg =
eregi_replace("([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])","<a
href=\"\\1://\\2\\3\" target=\"_blank\">\\1://\\2\\3</a>", $msg);
The only problem is that if a correctly formatted link is already in the
text, then this routine tries to add an additional href and it gets all
messed up. Is there any way that I can use this algorithm and logically
tell it not to do the replace if the anchor tags are already in place? I
can't just search for an anchor <a> tag because there can be several in the
text.
Example:
$myLink = "<a href=\"http://www.mytest.com\" target=\"_n\">Testing</a>";
echo makeLink($myLink);
Creates $msg =
<a href="<a href="http://www.mytest.com"
target="_blank">http://www.mytest.com</a>" target="_n">Testing</a>
Any suggestions?
"Gaylen Fraley" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I have need to be able to replace text within a string to turn it into a
> link. In other words, I might have a phrase lik:
>
> "blah, blah, blah, please visit my site at www.mysite.com. blah,
> blah,blah".
>
> I need to have the string converted to "blah, blah, blah, please visit my
> site at http://www.mysite.com. blah, blah,blah". The link might have
more
> than 3 sections and won't necessarily end in .com (.net,.com.nl, etc.).
>
> Here is what I have been testing (then I get stuck):
> $myLink = "Please visit my web site at www.mysite.com. You will be glad
you
> did!";
> $repLink = preg_replace("/(www.)/i","<a href=http://\\1",$myLink);
>
> which yields
> Please visit my web site at <a href=http://www.mysite.com. You will be
glad
> you did!
>
> What I would need is
> Please visit my web site at <a
> href=http://www.mysite.com>www.mysite.com</a>. You will be glad you did!
>
> To be truthful, pattern matching is giving me migraines! Programming has
> always been natural to me (32 years of it), but this challenge (eregi,
> preg_match,etc.) is making me crazy! Can someone recommend a good
tutorial
> or book on this subject?
>
> Thanks!
>
>
>
--- End Message ---
--- Begin Message ---
have a look at eval()
Paul Roberts
[EMAIL PROTECTED]
++++++++++++++++++++++++
From: "Lauri Vain" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 12, 2002 11:44 AM
Subject: [PHP] multiple replaces...
Hello there,
I have about 30 markers in the text which need to be replaced with the value
of a variable or an array.
Common sense comes up with
eregi_replace("!one!","blah",eregi_replace("!heh!",'foobar',eregi_replace("b
lah","ho-ho-ho",text)));
The list above could go on and on... I'm sure there are better ways to
replace many markers or spans of text with something else. A loop? Something
even more easier and better?
Thanks,
Lauri
--
Tharapita Creations
[dynamic web applications]
[EMAIL PROTECTED]
Mobile: +372 53 410 610
--
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]
--- End Message ---
--- Begin Message ---
try str_replace() ... it allows you to pass an array into the replace
function.
/dkm
----- Original Message -----
From: "Paul Roberts" <[EMAIL PROTECTED]>
To: "Lauri Vain" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, January 12, 2002 4:35 PM
Subject: Re: [PHP] multiple replaces...
> have a look at eval()
>
> Paul Roberts
> [EMAIL PROTECTED]
> ++++++++++++++++++++++++
> From: "Lauri Vain" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, January 12, 2002 11:44 AM
> Subject: [PHP] multiple replaces...
>
>
> Hello there,
>
> I have about 30 markers in the text which need to be replaced with the
value
> of a variable or an array.
>
> Common sense comes up with
>
eregi_replace("!one!","blah",eregi_replace("!heh!",'foobar',eregi_replace("b
> lah","ho-ho-ho",text)));
>
> The list above could go on and on... I'm sure there are better ways to
> replace many markers or spans of text with something else. A loop?
Something
> even more easier and better?
>
> Thanks,
> Lauri
> --
> Tharapita Creations
> [dynamic web applications]
> [EMAIL PROTECTED]
> Mobile: +372 53 410 610
>
>
>
> --
> 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]
>
>
>
>
>
> --
> 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]
>
--- End Message ---
--- Begin Message ---
----- Original Message -----
From: Dennis Moore <[EMAIL PROTECTED]>
To: Paul Roberts <[EMAIL PROTECTED]>; Lauri Vain
<[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: 12. sijeÄanj 2002 23:33
Subject: Re: [PHP] multiple replaces...
> try str_replace() ... it allows you to pass an array into the replace
> function.
>
> /dkm
>
> ----- Original Message -----
> From: "Paul Roberts" <[EMAIL PROTECTED]>
> To: "Lauri Vain" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Saturday, January 12, 2002 4:35 PM
> Subject: Re: [PHP] multiple replaces...
>
>
> > have a look at eval()
> >
> > Paul Roberts
> > [EMAIL PROTECTED]
> > ++++++++++++++++++++++++
> > From: "Lauri Vain" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Saturday, January 12, 2002 11:44 AM
> > Subject: [PHP] multiple replaces...
> >
> >
> > Hello there,
> >
> > I have about 30 markers in the text which need to be replaced with the
> value
> > of a variable or an array.
> >
> > Common sense comes up with
> >
>
eregi_replace("!one!","blah",eregi_replace("!heh!",'foobar',eregi_replace("b
> > lah","ho-ho-ho",text)));
> >
> > The list above could go on and on... I'm sure there are better ways to
> > replace many markers or spans of text with something else. A loop?
> Something
> > even more easier and better?
> >
> > Thanks,
> > Lauri
> > --
> > Tharapita Creations
> > [dynamic web applications]
> > [EMAIL PROTECTED]
> > Mobile: +372 53 410 610
> >
> >
> >
> > --
> > 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]
> >
> >
> >
> >
> >
> > --
> > 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]
> >
>
>
> --
> 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]
>
--- End Message ---
--- Begin Message ---
Hi!
thanks for reviewing this email.
I have wrote this script and I have checked it but for some reasons (I
don't know what) it doesn't work.
Could any body please check and give some feedback please?
<?PHP
include("heading.inc");
echo "Result :\n"; ------------------------->>> THIS DOESN'T GIVE ME A
NEW LINE- WHY ?????
//CONNECT TO SERVER
include("connect.inc");
//CONNECT DATABASE
include("select_db.inc");
$query = "select * from main_table where item_type = '$type' and class =
'$class' ";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
echo ("$row[item_id]\n"); ------------------------->>>> THIS DOESN'T
GIVE ME A NEW LINE EITHER, WHY ??????
while ($row = mysql_fetch_array($result))
{
echo "$row[item_type]" , "$row[class]";
}
?>
Any reply is greatly appriciated
Regards,
Dani
--- End Message ---
--- Begin Message ---
Dani -
D> echo "Result :\n"; ------------------------->>> THIS DOESN'T GIVE ME A
D> NEW LINE- WHY ?????
If you look at the source code of your page you'll see a new line
there.
If you want a new line in the browser output, you must place a <BR> at
that point, not a \n since it's HTML.
Hope this helps.
Gianluca
D> //CONNECT TO SERVER
D> include("connect.inc");
D> //CONNECT DATABASE
D> include("select_db.inc");
D> $query = "select * from main_table where item_type = '$type' and class =
D> '$class' ";
D> $result = mysql_query($query);
D> $row = mysql_fetch_array($result);
D> echo ("$row[item_id]\n"); ------------------------->>>> THIS DOESN'T
D> GIVE ME A NEW LINE EITHER, WHY ??????
D> while ($row = mysql_fetch_array($result))
D> {
D> echo "$row[item_type]" , "$row[class]";
D> }
?>>
D> Any reply is greatly appriciated
D> Regards,
D> Dani
--
ALBASOFTWARE
C/ Mallorca 186 - 3º 1ª
08036 Barcelona (Spain)
Tel./Fax +34 934549324
[EMAIL PROTECTED]
http://www.gianlucabaldo.com
http://www.phpauction.org
--- End Message ---
--- Begin Message ---
I assume you your displaying a web page. HTML ignores \n ... You need to
insert a <br>.
----- Original Message -----
From: "Dani" <[EMAIL PROTECTED]>
To: "PHP LIST" <[EMAIL PROTECTED]>
Sent: Saturday, January 12, 2002 8:25 PM
Subject: [PHP] Please "\n" problem????
> Hi!
>
> thanks for reviewing this email.
>
> I have wrote this script and I have checked it but for some reasons (I
> don't know what) it doesn't work.
>
> Could any body please check and give some feedback please?
>
> <?PHP
>
> include("heading.inc");
>
> echo "Result :\n"; ------------------------->>> THIS DOESN'T GIVE ME A
> NEW LINE- WHY ?????
>
>
> //CONNECT TO SERVER
> include("connect.inc");
>
> //CONNECT DATABASE
> include("select_db.inc");
>
> $query = "select * from main_table where item_type = '$type' and class =
> '$class' ";
> $result = mysql_query($query);
>
> $row = mysql_fetch_array($result);
>
> echo ("$row[item_id]\n"); ------------------------->>>> THIS DOESN'T
> GIVE ME A NEW LINE EITHER, WHY ??????
>
> while ($row = mysql_fetch_array($result))
> {
> echo "$row[item_type]" , "$row[class]";
> }
>
> ?>
>
>
> Any reply is greatly appriciated
>
> Regards,
> Dani
>
>
> --
> 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]
>
--- End Message ---
--- Begin Message ---
Thanks Alot Guys!!!!!!!
It works!
now my next question is :
When do I actually use "\n"???
Thank you so much!
Gianluca Baldo wrote:
> Dani -
>
> D> echo "Result :\n"; ------------------------->>> THIS DOESN'T GIVE ME A
> D> NEW LINE- WHY ?????
> If you look at the source code of your page you'll see a new line
> there.
> If you want a new line in the browser output, you must place a <BR> at
> that point, not a \n since it's HTML.
>
> Hope this helps.
> Gianluca
>
> D> //CONNECT TO SERVER
> D> include("connect.inc");
>
> D> //CONNECT DATABASE
> D> include("select_db.inc");
>
> D> $query = "select * from main_table where item_type = '$type' and class =
> D> '$class' ";
> D> $result = mysql_query($query);
>
> D> $row = mysql_fetch_array($result);
>
> D> echo ("$row[item_id]\n"); ------------------------->>>> THIS DOESN'T
> D> GIVE ME A NEW LINE EITHER, WHY ??????
>
> D> while ($row = mysql_fetch_array($result))
> D> {
> D> echo "$row[item_type]" , "$row[class]";
> D> }
>
> ?>>
>
> D> Any reply is greatly appriciated
>
> D> Regards,
> D> Dani
>
> --
> ALBASOFTWARE
> C/ Mallorca 186 - 3º 1ª
> 08036 Barcelona (Spain)
> Tel./Fax +34 934549324
> [EMAIL PROTECTED]
> http://www.gianlucabaldo.com
> http://www.phpauction.org
--- End Message ---
--- Begin Message ---
The \n can be useful for when you want to look at the source code from an
HTML page. It will not make a new line within the browser, but it sure
can make reading the source alot easier... otherwise all of the code goes
onto the same line... which also can be useful if you want it be difficult
for others to take your source code!
..
On Sun, 13 Jan 2002, Dani wrote:
> Thanks Alot Guys!!!!!!!
> It works!
>
> now my next question is :
>
> When do I actually use "\n"???
>
> Thank you so much!
>
> Gianluca Baldo wrote:
>
> > Dani -
> >
> > D> echo "Result :\n"; ------------------------->>> THIS DOESN'T GIVE ME A
> > D> NEW LINE- WHY ?????
> > If you look at the source code of your page you'll see a new line
> > there.
> > If you want a new line in the browser output, you must place a <BR> at
> > that point, not a \n since it's HTML.
> >
> > Hope this helps.
> > Gianluca
> >
> > D> //CONNECT TO SERVER
> > D> include("connect.inc");
> >
> > D> //CONNECT DATABASE
> > D> include("select_db.inc");
> >
> > D> $query = "select * from main_table where item_type = '$type' and class =
> > D> '$class' ";
> > D> $result = mysql_query($query);
> >
> > D> $row = mysql_fetch_array($result);
> >
> > D> echo ("$row[item_id]\n"); ------------------------->>>> THIS DOESN'T
> > D> GIVE ME A NEW LINE EITHER, WHY ??????
> >
> > D> while ($row = mysql_fetch_array($result))
> > D> {
> > D> echo "$row[item_type]" , "$row[class]";
> > D> }
> >
> > ?>>
> >
> > D> Any reply is greatly appriciated
> >
> > D> Regards,
> > D> Dani
> >
> > --
> > ALBASOFTWARE
> > C/ Mallorca 186 - 3º 1ª
> > 08036 Barcelona (Spain)
> > Tel./Fax +34 934549324
> > [EMAIL PROTECTED]
> > http://www.gianlucabaldo.com
> > http://www.phpauction.org
>
>
> --
> 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]
>
--- End Message ---
--- Begin Message ---
Hi Again!
Why does this print only one record?
1. I have checked on the table on MYSQL and I have 2 records with this
data.
2. Can I actually use the word "and" twice or three times for filtering
the data that I need during query?? (example: $query = "select * from
main_table where item_type = 'hotel' and class = 'melati' and price =
'200' and facilities = 'swimming pool' "
Could some body help please???
here is my code
...
$query = "select * from main_table where item_type = 'hotel' and class =
'melati'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
echo "$row[item_id]","<BR>";
while ($row = mysql_fetch_array($result))
{
echo "WHILE RESULT","$row[item_type]","<BR>","$row[class]";
}
thank you again!
regards,
Dani
--- End Message ---
--- Begin Message ---
Dani wrote:
> Hi Again!
>
> Why does this print only one record?
>
> 1. I have checked on the table on MYSQL and I have 2 records with this
> data.
> 2. Can I actually use the word "and" twice or three times for filtering
> the data that I need during query?? (example: $query = "select * from
> main_table where item_type = 'hotel' and class = 'melati' and price =
> '200' and facilities = 'swimming pool' "
>
#2 - yes. that's what SQL is all about...
#1 - Why do the $row=xxxx, then also do it in a while loop? Why not
just do it in a while loop? I'm not sure that'd necessarily help in this
case (most likely won't) but it would certainly be less typing in the
future.
Are you postive 2 rows match the 'hotel' and 'melati'?
> Could some body help please???
>
> here is my code
>
> ...
> $query = "select * from main_table where item_type = 'hotel' and class =
> 'melati'";
> $result = mysql_query($query);
> $row = mysql_fetch_array($result);
> echo "$row[item_id]","<BR>";
> while ($row = mysql_fetch_array($result))
> {
> echo "WHILE RESULT","$row[item_type]","<BR>","$row[class]";
> }
>
--------------------------------
Michael Kimsal
PHP Training Courses
http://www.tapinternet.com/php/
734-480-9961
--- End Message ---
--- Begin Message ---
move the following inside your while loop
echo "$row[item_id]","<BR>";
----- Original Message -----
From: "Dani" <[EMAIL PROTECTED]>
To: "PHP LIST" <[EMAIL PROTECTED]>
Sent: Saturday, January 12, 2002 8:54 PM
Subject: [PHP] Print ONCE ONLY?????
>
> Hi Again!
>
> Why does this print only one record?
>
> 1. I have checked on the table on MYSQL and I have 2 records with this
> data.
> 2. Can I actually use the word "and" twice or three times for filtering
> the data that I need during query?? (example: $query = "select * from
> main_table where item_type = 'hotel' and class = 'melati' and price =
> '200' and facilities = 'swimming pool' "
>
> Could some body help please???
>
> here is my code
>
> ...
> $query = "select * from main_table where item_type = 'hotel' and class =
> 'melati'";
> $result = mysql_query($query);
> $row = mysql_fetch_array($result);
> echo "$row[item_id]","<BR>";
> while ($row = mysql_fetch_array($result))
> {
> echo "WHILE RESULT","$row[item_type]","<BR>","$row[class]";
> }
>
>
> thank you again!
>
> regards,
> Dani
>
>
>
> --
> 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]
>
--- End Message ---
--- Begin Message ---
Dani wrote:
> Hi Again!
>
> Why does this print only one record?
>
> 1. I have checked on the table on MYSQL and I have 2 records with this
> data.
> 2. Can I actually use the word "and" twice or three times for filtering
> the data that I need during query?? (example: $query = "select * from
> main_table where item_type = 'hotel' and class = 'melati' and price =
> '200' and facilities = 'swimming pool' "
>
#2 - yes. that's what SQL is all about...
#1 - Why do the $row=xxxx, then also do it in a while loop? Why not
just do it in a while loop? I'm not sure that'd necessarily help in this
case (most likely won't) but it would certainly be less typing in the
future.
Are you postive 2 rows match the 'hotel' and 'melati'?
> Could some body help please???
>
> here is my code
>
> ...
> $query = "select * from main_table where item_type = 'hotel' and class =
> 'melati'";
> $result = mysql_query($query);
> $row = mysql_fetch_array($result);
> echo "$row[item_id]","<BR>";
> while ($row = mysql_fetch_array($result))
> {
> echo "WHILE RESULT","$row[item_type]","<BR>","$row[class]";
> }
>
--------------------------------
Michael Kimsal
PHP Training Courses
http://www.tapinternet.com/php/
734-480-9961
--- End Message ---
--- Begin Message ---
I think this is actually the problem
The first time you do $row = mysql_fetch_array($result); it reads the first
row. Then you don't do anything with that data, but move on to the next one
right away in the while:
while ($row = mysql_fetch_array($result))
and only then you print out the data. So you are always skipping the first
record.
Sincerely,
Pavel Kharitonov
Project Manager
Intechnic Corporation
http://www.intechnic.com
Phone: (847) 816-1231
-----Original Message-----
From: Michael Kimsal [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 12, 2002 5:14 PM
To: Dani
Cc: PHP LIST
Subject: [PHP] Re: Print ONCE ONLY?????
Dani wrote:
> Hi Again!
>
> Why does this print only one record?
>
> 1. I have checked on the table on MYSQL and I have 2 records with this
> data.
> 2. Can I actually use the word "and" twice or three times for filtering
> the data that I need during query?? (example: $query = "select * from
> main_table where item_type = 'hotel' and class = 'melati' and price =
> '200' and facilities = 'swimming pool' "
>
#2 - yes. that's what SQL is all about...
#1 - Why do the $row=xxxx, then also do it in a while loop? Why not
just do it in a while loop? I'm not sure that'd necessarily help in this
case (most likely won't) but it would certainly be less typing in the
future.
Are you postive 2 rows match the 'hotel' and 'melati'?
> Could some body help please???
>
> here is my code
>
> ...
> $query = "select * from main_table where item_type = 'hotel' and class =
> 'melati'";
> $result = mysql_query($query);
> $row = mysql_fetch_array($result);
> echo "$row[item_id]","<BR>";
> while ($row = mysql_fetch_array($result))
> {
> echo "WHILE RESULT","$row[item_type]","<BR>","$row[class]";
> }
>
--------------------------------
Michael Kimsal
PHP Training Courses
http://www.tapinternet.com/php/
734-480-9961
--
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]
--- End Message ---
--- Begin Message ---
Thanks very much!
it works!
Sincerely,
Dani
Thomas Holton wrote:
> You should be able to use "and" as many times as you want.
> You should also make sure that the query you are making below is returning
> the number of records you think it should be:
> $numrecords = mysql_num_rows($result);
> then you can set up a loop to get the results:
> while ($i < $numrecords)
> { $col_name = mysql_result($result, $i, "column name");
> ..
> print "<br>$col_name ..."
> $i++;
> # for each row
> }
>
> hope this helps.
>
> ..
>
> On Sun, 13 Jan 2002, Dani wrote:
>
> >
> > Hi Again!
> >
> > Why does this print only one record?
> >
> > 1. I have checked on the table on MYSQL and I have 2 records with this
> > data.
> > 2. Can I actually use the word "and" twice or three times for filtering
> > the data that I need during query?? (example: $query = "select * from
> > main_table where item_type = 'hotel' and class = 'melati' and price =
> > '200' and facilities = 'swimming pool' "
> >
> > Could some body help please???
> >
> > here is my code
> >
> > ...
> > $query = "select * from main_table where item_type = 'hotel' and class =
> > 'melati'";
> > $result = mysql_query($query);
> > $row = mysql_fetch_array($result);
> > echo "$row[item_id]","<BR>";
> > while ($row = mysql_fetch_array($result))
> > {
> > echo "WHILE RESULT","$row[item_type]","<BR>","$row[class]";
> > }
> >
> >
> > thank you again!
> >
> > regards,
> > Dani
> >
> >
> >
> > --
> > 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]
> >
--- End Message ---
--- Begin Message ---
Does anyone know how to give a select pulldown box a default value from a PHP variable?
I've been able to figure out how to pipe data into every type in <input > type of form
element except for a <select > element. Any solutions would be helpful!
Dean
--- End Message ---
--- Begin Message ---
----- Original Message -----
From: hugh danaher <[EMAIL PROTECTED]>
To: Dean Householder <[EMAIL PROTECTED]>
Sent: Saturday, January 12, 2002 7:12 PM
Subject: Re: [PHP] Piping data into a select box
> Dean, give this a try.
>
> <form action="<?php print $php_self?>" method="post">
> <?php
> <select type=text name=table STYLE=width:180px> <option> ";
> for ($i=0;$i<=$num;$i++)
> {
> print "<option>".mysql_tablename($tables,$i); // or. i.e.
> $some_array[$i]
> }
> print "</select>";
>
> echo "table ".$table;
>
> hugh
>
>
> ----- Original Message -----
> From: Dean Householder <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Saturday, January 12, 2002 6:01 PM
> Subject: [PHP] Piping data into a select box
>
>
> Does anyone know how to give a select pulldown box a default value from a
> PHP variable?
>
> I've been able to figure out how to pipe data into every type in <input >
> type of form element except for a <select > element. Any solutions would
be
> helpful!
>
> Dean
>
>
--- End Message ---
--- Begin Message ---
Hi Dean,
> Does anyone know how to give a select pulldown box a default value
> from a PHP variable?
<?
function generate_option_list ($key_value,$set) {
// This function will return option list and set the selected attribute
// $key_value : the associative array which contain the key and the value for each
option
// $set : the value to be selected by deafult
//
// Usage: for example we want to have a dropdown list of month, and set February as
selected
//
// $key_value=array("01"=>"January","02"=>"February",...);
// $option_list=generate_option_list($key_value,"02");
// //$option_list now contain text <option value='01'>January</option>
// // <option value='02' selected>February</option>
//
// NOTE: This will only create the <OPTION> tag, without the <SELECT> tag
//
while ( list($key,$value) = each($key_value) ) {
if ($key==$set) {$var.="<option value='$key' selected>$value</option>";}
else {$var.="<option value='$key'>$value</option>";}
}
return $var;
}
?>
--
Jimmy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Leave loved ones with loving words, it may be the last time you see them
--- End Message ---
--- Begin Message ---
Hopefully a quick question:
I'm using the PHP date() function on my site, but since my hosting company
(Pair Networks) is on the East Coast and I'm on the West Coast, everything
shows as three hours later (for most of my visitors, anyway). Pair tells me
there's no setting I can make on my account to change the server time zone.
Can anyone recommend a way to set an offset for the date() function in PHP?
(I searched on php.net and couldn't find anything.)
Thanks for any help!
Marvin
--- End Message ---
--- Begin Message ---
Is there a way to ensure that the data in a form is not cleared when you
click the back button?
I have numerous forms that all have some PHP error checking. The standard
error page has a simple JavaScript back command. Every time I click it (or
the browser's back button), it clears the form on the previous page. I
really don't want to have to keep all the data and repopulate the form if I
don't have to.
thanks,
alastair
--- End Message ---
--- Begin Message ---
I'm not exactly sure what you are asking.. Are you wondering if it is safer
to have register_globals on or off? If it is off, you will have to access
all the globals through the $HTTP_*_VARS variables. They are quite a bit
safer but require a bit of getting used too (just look at my posts in the
last few days..).
cheers,
alastair
"Gerard Samuel" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hey all. I was wondering. Is it safe to use HTTP global variables ie
> $HTTP_POST_VARS etc in my scripts?
> Thought I read somewhere that they weren't safe.
> Got a lot of forms to work with, it sure would make life easier...
>
--- End Message ---