Re: [PHP] OT(?): mod_rewrite not passing GET variables to php

2003-10-03 Thread Steven Jarvis
On Wednesday, October 1, 2003, at 04:16  PM, Leif K-Brooks wrote:

Steven Jarvis wrote:

I'm just starting to experiment with mod_rewrite on Apache 1.3.x and 
php 4.3.3. Register_globals is off.

I have the following rules in my .htaccess file (which sits in the 
site's root dir along with paper.php):

RewriteEngine On
RewriteRule ^/([a-z]+)/([a-z]+)/$ paper.php?paper=$1section=$2 [L]
The browser gets served up paper.php, but I can't access the 
variables that should be in $1 and $2. They're supposed to be GET 
variables, right?

I've tried accessing them with $_GET[varname] and 
$_REQUEST[varname]  (and directly with $varname, even though 
register_globals is off), but I get nothing.

Can someone point out the (probably obvious) problem I'm having?

Try this (I'm no mod_rewrite expert, so no promises):

RewriteEngine On
RewriteRule /^([a-z]+)\/([a-z]+)$/ paper.php?paper=$1section=$2 [L]
Thanks for the help, but nope, same results. Still no variables are 
passed to the page.

I think there may be an issue with my Apache install. I'm going to 
explore that today.

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


[PHP] OT(?): mod_rewrite not passing GET variables to php

2003-10-01 Thread Steven Jarvis
I'm just starting to experiment with mod_rewrite on Apache 1.3.x and 
php 4.3.3. Register_globals is off.

I have the following rules in my .htaccess file (which sits in the 
site's root dir along with paper.php):

RewriteEngine On
RewriteRule ^/([a-z]+)/([a-z]+)/$ paper.php?paper=$1section=$2 [L]
The browser gets served up paper.php, but I can't access the variables 
that should be in $1 and $2. They're supposed to be GET variables, 
right?

I've tried accessing them with $_GET[varname] and 
$_REQUEST[varname]  (and directly with $varname, even though 
register_globals is off), but I get nothing.

Can someone point out the (probably obvious) problem I'm having?

thanks,

Steven

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


Re: [PHP] storing an array in mysql - what's the best data type?

2002-07-09 Thread Steven Jarvis

Kevin,

 I have an array that I want to store in a field of a mysql db. I've got
 it set as type text currently, but when I retrieve it, I can't get the
 arrary to parse.

 If I look at the listings in the mysql cli, it just says Array for
 that field.

 Here's my retrieval code:

 $storyid = $_REQUEST['storyid'];

 $db = mysql_connect(localhost, user, pass) or die (Could Not
 connect to db.);
 mysql_select_db(storiestest, $db) or die(Could not select 
 database.);
 $query = SELECT * FROM ADGstories WHERE (storyid='$storyid');
 $results = mysql_query($query, $db);
 $num_results = mysql_num_rows($results);

 for ($i=0; $i  $num_results; $i++)
 {
 $row = mysql_fetch_array($results);
 while ($element = each($row))
 {
 echo $element[key];
 echo : ;
 echo $element[value];
 echo br\n;

 $varname = $element[key];
 $$varname = $element[value];
 }

 echo h2$headline/h2\n
 p class='byline'$byline/p\n;

 // just as a test, not looping through the array. Loop code not
 included.
 echo p class='bodycopy'$bodycopy[0]/p\n;
 }

 Even with the version at the end there, I get A echoed to the screen.

 If I try a print_r($bodycopy), it says Array.

 Where did I screw up?


 You can store arrays as strings with..

 $str = serialize($ary);

 .. and turn a serialized string back into an array with..

 $ary = unserialize($str);

 The string can be stored in either a TEXT or TINYTEXT field.  Is this 
 what
 you wanted to know?

Yes. That worked.



 I had trouble following your code after the for loop.
 $headline, $byline and $bodycopy are variable names stored in the 
 database?

Yes. Sorry about that. I should have explained what those variables were.

In any case, your solution worked for me.

thanks!

Steven

--
Steven Jarvis
Web Publishing Manager/Web Developer
NWAnews.com:
Arkansas Democrat-Gazette, Northwest Edition
Northwest Arkansas Times
Benton County Daily Record


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




[PHP] storing an array in mysql - what's the best data type?

2002-07-08 Thread Steven Jarvis

I have an array that I want to store in a field of a mysql db. I've got
it set as type text currently, but when I retrieve it, I can't get the
arrary to parse.

If I look at the listings in the mysql cli, it just says Array for
that field.

Here's my retrieval code:

$storyid = $_REQUEST['storyid'];

$db = mysql_connect(localhost, user, pass) or die (Could Not
connect to db.);
mysql_select_db(storiestest, $db) or die(Could not select database.);
$query = SELECT * FROM ADGstories WHERE (storyid='$storyid');
$results = mysql_query($query, $db);
$num_results = mysql_num_rows($results);

for ($i=0; $i  $num_results; $i++)
{
$row = mysql_fetch_array($results);
while ($element = each($row))
{
echo $element[key];
echo : ;
echo $element[value];
echo br\n;

$varname = $element[key];
$$varname = $element[value];
}

echo h2$headline/h2\n
 p class='byline'$byline/p\n;

 // just as a test, not looping through the array. Loop code not
included.
echo p class='bodycopy'$bodycopy[0]/p\n;
}

Even with the version at the end there, I get A echoed to the screen.

If I try a print_r($bodycopy), it says Array.

Where did I screw up?

Thanks!

Steven

--
Steven Jarvis
Web Publishing Manager/Web Developer
NWAnews.com:
Arkansas Democrat-Gazette, Northwest Edition
Northwest Arkansas Times
Benton County Daily Record


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




Re: [PHP] long PHP array and HTML forms question

2002-06-06 Thread Steven Jarvis

Jason Wong wrote:
 Page 2:
 I want the user to be able to use none, some, or all of the fields, 
 so I
 don't know how many elements will be in the array.

 $color[] = $_POST[color];

 That should be:

   $color = $_POST[color];

 Actually from your results below it seems like you've enabled 
 register_globals
 and it's not necessary to explicit (re)assign $color.

Right. I'm used to working on a machine that doesn't have 
register_globals enabled, so it's just habit. Unfortunately, that 
particular hosting provider enables them.




 First question: is there something I can do at this point to cut the
 empty entries

 foreach ($color as $key = $val) {
   if ($val) {
 $tmp[] = $val;
   }
 }
 $color = $tmp;

 That will remove empty values from $color.

Ahh. That's exactly what I needed!

Thanks,

Steven


Steven Jarvis
Web Developer
Arkansas Democrat-Gazette
Northwest Edition


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




[PHP] long PHP array and HTML forms question

2002-06-05 Thread Steven Jarvis

I'm trying to store an array in a mysql db. I'm creating the array 
variable through an html form and passing it to the page where I store 
it in the db. I want to create the array with a form, store it in the 
db, then display it in another form with a select statement. However, 
I'm getting extra array elements, including another array in the final 
element. I can't figure out how to deal with this extraneous data.

Page 1:
The insertion form looks like this:
form method=post action=arraytest.php
COLORS:br /
input type=text name=color[] size=30 /br /
input type=text name=color[] size=30 /br /
input type=text name=color[] size=30 /br /
input type=text name=color[] size=30 /br /
input type=text name=color[] size=30 /br /
input type=text name=color[] size=30 /br /
input type=submit value=do it! /
/form

That's five input fields.

Page 2:
I want the user to be able to use none, some, or all of the fields, so I 
don't know how many elements will be in the array.

$color[] = $_POST[color];

I'm testing the incoming array with:

while ($element = each($color))
{
echo $element[key];
echo : ;
echo $element[value];
echo br\n;
}

And I get results like this printed to the browser (I always get seven 
entries, including the last array entry):

0: green
1: black
2: blue
3:
4:
5:
6: Array

First question: is there something I can do at this point to cut the 
empty entries (and that extra seventh array entry) out of the array so 
that it's clean going into the db?


So, I insert that array into the db like so:
// db connectivity stuff
INSERT INTO items (color) VALUES ( '$color');
// there are other variables, but I'm trying to keep this as clean as 
possible.



Then, I have this on the page that pulls the data from the db:
...
$num_results = mysql_num_rows($results);

for ($i=0; $i  $num_results; $i++)
{
$row = mysql_fetch_array($results);
$color[] = $row[color];
echo form method='post' action='someotherpage.php';
echo select name='color';
$colorcount = count($color);
echo !-- colorcount: $colorcount --;
for($x = 0; $x  $colorcount - 1; $x++)
{
echo option 
value='$color[$x]'$color[$x]/option\n;
}
echo /select/form;
}   

However, I'm putting that bad array in the database, and I still get 
extra option entries, because I have no idea how many extras to remove. 
So, I feel like I should be doing something BEFORE I do the db insert. 
Other than that, the db insert and select work just fine (say, if I set 
the values of that array manually in the php code).

Any suggestions would be very helpful!

Thanks,

Steven

--
Steven Jarvis
Web Developer
Arkansas Democrat-Gazette
Northwest Edition


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




[PHP] Getting substring of text for first paragraph

2002-05-12 Thread Steven Jarvis

I want to do the following:

Big chunk of text is stored in variable $a. Paragraph breaks are 
signalled by two line breaks.

I want to just extract the first paragraph (i.e., all the text up to the 
first set of two line breaks) from $a.

How would I do this?

I tried exploding $a into an array, then doing a while loop inside a for 
loop, but it was taking WAY too long to execute (it was timing out).

Is there an easy way to do this that I'm just overlooking?

Thanks,

Steven


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




[PHP] new $_SESSION variables vs. session_register/unregister

2002-03-28 Thread Steven Jarvis

The manual says:

 If you are using $HTTP_SESSION_VARS/$_SESSION, do not use 
 session_register(), session_is_registered() and session_unregister().

If that's the case, how do I unregister $_SESSION variables? Do I just 
use unset() or is there another way?

I'm pretty new to PHP and I'm just getting started using sessions. The 
book I'm using to learn sessions isn't new enough to include how to deal 
with the new $_SESSION global variables array, and the manual's dire 
warning isn't explained thoroughly enough for me.

Thanks!

Steven

--
Steven Jarvis
Web Developer
Arkansas Democrat-Gazette
Northwest Edition
NWAnews.com


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




Re: [PHP] new $_SESSION variables vs. session_register/unregister

2002-03-28 Thread Steven Jarvis

Uh... doh!

I was reading this:

Note: If $_SESSION (or $HTTP_SESSION_VARS for PHP 4.0.6 or less) is 
used, use unset() to unregister a session variable.

incorrectly.

In my haste, I was basically not parsing the parentheses. I see now that 
I just treat the $_SESSION variables like any other variable and use 
unset() and isset() (in place of session_is_registered().

I apologize for the noise.

Steven


On Thursday, March 28, 2002, at 01:21  PM, Steven Jarvis wrote:

 The manual says:

 If you are using $HTTP_SESSION_VARS/$_SESSION, do not use 
 session_register(), session_is_registered() and session_unregister().

 If that's the case, how do I unregister $_SESSION variables? Do I just 
 use unset() or is there another way?

 I'm pretty new to PHP and I'm just getting started using sessions. The 
 book I'm using to learn sessions isn't new enough to include how to 
 deal with the new $_SESSION global variables array, and the manual's 
 dire warning isn't explained thoroughly enough for me.

 Thanks!

 Steven

 --
 Steven Jarvis
 Web Developer
 Arkansas Democrat-Gazette
 Northwest Edition
 NWAnews.com


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



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




Re: [PHP] Mac Classic and PHP...

2002-03-18 Thread Steven Jarvis


On Monday, March 18, 2002, at 03:22 PM, Chuck PUP Payne wrote:

 Does anyone know a good web server beside WebStar for the Mac Classic 
 OS,
 that will allow you to run PHP with it? I have a client that is looking 
 for
 such an animal. I recommended WebStar because I know it will let you 
 run cg,
 but I am not sure about PHP. WebStar is the only professional web server
 that I know of of Mac Classic. I don't think there is such an animal 
 for the
 classic OS. I have tried to talk them into move to OS 10.1.3, but that 
 like
 talking to the wall.  Also I need to know where I can find free ODBC 
 drivers
 that will let them contact to MYSQL or Filemaker pro.


WebTen from Tenon (http://www.tenon.com) is an implementation of Apache 
for MacOS Classic. It runs at least through PHP 3, I think, plus all the 
other stuff you can run with Apache (perl, etc.).

It's not as easy to administer as WebSTAR, but it's in some ways more 
flexible and more powerful.

HTH,

Steven

--
Steven Jarvis
Web Developer
Arkansas Democrat-Gazette
Northwest Edition


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




[PHP] escaping ?

2002-02-08 Thread Steven Jarvis

I'm trying to do some string replaces on XML files to import them into a 
prprietary db that doesn't understand XML.

I need to strip the XML tags out of the file.

However, when I use this line:

$contents = str_replace('?xml version=1.0?', '', $contents);

The ? in the string ends my php block.


I know there's an easy answer to this, and I'm probably just suffering 
from Friday afternoon burnout, but can someone let me know how to escape 
those so that I can search for them in the string?

thanks,

Steven


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




[PHP] GetImageSize and iptcparse problems

2002-02-06 Thread Steven Jarvis

I've read the manual, and I'm still stuck, partially due to the manual 
itself. This is the first time I've dealt with this particular issue 
(parsing IPTC info from JPEGs).

The example provided in the manual entry on GetImageSize:

?php
 $size = GetImageSize (testimg.jpg,$info);
 if (isset ($info[APP13])) {
 $iptc = iptcparse ($info[APP13]);
 var_dump ($iptc);
 }
?

Gives me the following error on php 4.0.6:

Warning: Call-time pass-by-reference has been deprecated - argument 
passed by value; If you would like to pass it by reference, modify the 
declaration of getimagesize(). If you would like to enable call-time 
pass-by-reference, you can set allow_call_time_pass_reference to true in 
your INI file. However, future versions may not support this any longer.

I don't understand what I need to pass to getImageSize in order to 
extract the IPTC info.

Can someone point me in the right direction with this?

Thanks,

Steven



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




[PHP] newbie needs quick help with formatting dates

2002-01-23 Thread Steven Jarvis

I'm pretty new to PHP, and I need to re-format some date data, but I 
can't figure out how to do it. This may be a doh! question, but I've 
looked through the manual, and I can't seem to find what I'm looking for.

I have some dates formatted as mm/dd/yy that I need to convert to 
mmdd so I can store them correctly in a mysql db as a date-formatted 
field.

Does anyone have some php code that can do this for me?

thanks,

Steven


-- 
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]