RE: [PHP] Sessions - more testing

2003-10-11 Thread James Johnson
I've read Nelson's message and have added the following lines:

ini_set('session.save_path','ccb_sessions');
ini_set('session.use_trans_sid','off');
ini_set('session.gc_maxlifetime', '3600');

And still get the same page not found error. 

James



-Original Message-
From: James Johnson [mailto:[EMAIL PROTECTED] 
Sent: Saturday, October 11, 2003 3:46 PM
To: 'Lowell Allen'; 'PHP'
Subject: RE: [PHP] Sessions


Hi,

I checked the session settings with phpinfo(); I get the following values:
session_save_path = /tmp session.use_cookies = On session.use_trans_sid = 1

I've created a folder on the same level as all the pages called
"ccb_sessions" and have CHMOD it to 777. I have added the following snippet
above session_start: 
When navigating to my test page I get the following error:

Warning: open(/ccb_sessions/sess_bbbfa69631155d4097e0b0012c857c4a, O_RDWR)
failed: No such file or directory (2) in
/home/.paco/campuscb/campuscorkboard.com/MemberAccountDetails.php on line 2

Checking with my FTP client that file is there and has CHMOD values of 777.
I've done a Google search for "No such file or directory", found a bunch of
stuff for Python, nothing for PHP.

I then closed the browser, FTP'd to the ccb_sessions folder, deleted the
sess_bbbfa69631155d4097e0b0012c857c4a file and changed the session_save_path
to session_save_page("ccb_session");. When going to the test page, it
appears to loop several times, then gives me a "The page cannot be
displayed" message.

The server is (from phpinfo())Linux gaia 2.2.20, Server API is Apache.

Other ideas?
Thanks,
James

-Original Message-
From: Lowell Allen [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 10, 2003 6:23 PM
To: PHP
Subject: Re: [PHP] Sessions


> I'm trying to track down some issues with my site, and am trying to
> decide if it's a session variable issue. On a random basis, it appears 
> that session vars are being dumped, deleted, or unset, as the site 
> will break. Queries based on session vars don't work, session vars not 
> being displayed, etc. This seems to happen most often after a page has 
> been idle for a couple of minutes and a refresh is done on the page.
> 
> This is on a hosted site. I have checked the configuration settings
> with phpinfo(); and session support is enabled.
> 
> On all pages where I use $_SESSION[], I have  session_start();?>. This has been double checked.
> 
> 1) Do session vars timeout, or can they be set to timeout after a
> certain length of time?
> 2) Is there anything other than session_start(); that needs to be done 
> when using session vars?
> 3) What other things can I check for?

Most things are explained well by the online manual, and you should read and
re-read the session documentation. That said, I'll also say that the
documentation on sessions is not as informative as I'd like it to be, and I
still get reports of sessions expiring before they should.

Look at the output from echo phpinfo() and check these session configuration
options:

session.cookie_lifetime -- should be 0, lasts until quitting the browser
session.use_cookies -- should be on session.use_trans_sid -- should be on

Some things aren't explained very well, like what does
"session.gc_maxlifetime" mean? The maximum time before garbage collection to
remove session data that hasn't been used? But to minimize the chance of
garbage collection on a shared server wrecking your sessions, you can
specify a directory for saving session data. Create a directory (on the same
level as your directory of publicly-viewable files if you can) and before
the 'session_start();' line, do 'session_save_path("../my_sessions_dir");'.

Also be aware that circumstances on the client side can mess with session
cookies and cause the session to be lost, like using Internet Explorer with
Entourage in Mac OS X.

--
Lowell Allen

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

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

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



RE: [PHP] Sessions

2003-10-11 Thread James Johnson
Hi,

I checked the session settings with phpinfo(); I get the following values:
session_save_path = /tmp
session.use_cookies = On
session.use_trans_sid = 1

I've created a folder on the same level as all the pages called
"ccb_sessions" and have CHMOD it to 777.
I have added the following snippet above session_start: 
When navigating to my test page I get the following error:

Warning: open(/ccb_sessions/sess_bbbfa69631155d4097e0b0012c857c4a, O_RDWR)
failed: No such file or directory (2) in
/home/.paco/campuscb/campuscorkboard.com/MemberAccountDetails.php on line 2

Checking with my FTP client that file is there and has CHMOD values of 777.
I've done a Google search for "No such file or directory", found a bunch of
stuff for Python, nothing for PHP.

I then closed the browser, FTP'd to the ccb_sessions folder, deleted the
sess_bbbfa69631155d4097e0b0012c857c4a file and changed the session_save_path
to session_save_page("ccb_session");. When going to the test page, it
appears to loop several times, then gives me a "The page cannot be
displayed" message.

The server is (from phpinfo())Linux gaia 2.2.20, Server API is Apache.

Other ideas?
Thanks,
James

-Original Message-
From: Lowell Allen [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 10, 2003 6:23 PM
To: PHP
Subject: Re: [PHP] Sessions


> I'm trying to track down some issues with my site, and am trying to 
> decide if it's a session variable issue. On a random basis, it appears 
> that session vars are being dumped, deleted, or unset, as the site 
> will break. Queries based on session vars don't work, session vars not 
> being displayed, etc. This seems to happen most often after a page has 
> been idle for a couple of minutes and a refresh is done on the page.
> 
> This is on a hosted site. I have checked the configuration settings 
> with phpinfo(); and session support is enabled.
> 
> On all pages where I use $_SESSION[], I have  session_start();?>. This has been double checked.
> 
> 1) Do session vars timeout, or can they be set to timeout after a 
> certain length of time?
> 2) Is there anything other than session_start(); that needs to be done 
> when using session vars?
> 3) What other things can I check for?

Most things are explained well by the online manual, and you should read and
re-read the session documentation. That said, I'll also say that the
documentation on sessions is not as informative as I'd like it to be, and I
still get reports of sessions expiring before they should.

Look at the output from echo phpinfo() and check these session configuration
options:

session.cookie_lifetime -- should be 0, lasts until quitting the browser
session.use_cookies -- should be on session.use_trans_sid -- should be on

Some things aren't explained very well, like what does
"session.gc_maxlifetime" mean? The maximum time before garbage collection to
remove session data that hasn't been used? But to minimize the chance of
garbage collection on a shared server wrecking your sessions, you can
specify a directory for saving session data. Create a directory (on the same
level as your directory of publicly-viewable files if you can) and before
the 'session_start();' line, do 'session_save_path("../my_sessions_dir");'.

Also be aware that circumstances on the client side can mess with session
cookies and cause the session to be lost, like using Internet Explorer with
Entourage in Mac OS X.

--
Lowell Allen

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

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



[PHP] Sessions

2003-10-10 Thread James Johnson
Hi,

I'm trying to track down some issues with my site, and am trying to decide
if it's a session variable issue. On a random basis, it appears that session
vars are being dumped, deleted, or unset, as the site will break. Queries
based on session vars don't work, session vars not being displayed, etc.
This seems to happen most often after a page has been idle for a couple of
minutes and a refresh is done on the page.

This is on a hosted site. I have checked the configuration settings with
phpinfo(); and session support is enabled.

On all pages where I use $_SESSION[], I have . This has been double checked.

1) Do session vars timeout, or can they be set to timeout after a certain
length of time?
2) Is there anything other than session_start(); that needs to be done when
using session vars?
3) What other things can I check for?

Thanks,
James

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



[PHP] Major wierdness - ack!

2003-10-10 Thread James Johnson
Hi,

I'm getting so frustrated with this.

I have put some error trapping code in my site with the following code (an
included file):



I have a page that hits the database to display the records. One of the
columns is 'startDate'. I format this for display like this:



The page returns the following error:

[ERROR][8][Undefined index:
startDate][/home/.paco/campuscb/campuscorkboard.com/search_jobs.php:319][ERR
OR][8][strtotime() called with empty time
parameter][/home/.paco/campuscb/campuscorkboard.com/search_jobs.php:319]10/1
0/2003

If I comment out the error_reporting include file, the page renders fine. I
have checked the DB and the startDate column has a valid date in it.

Ideas?
Thanks,
James

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



[PHP] Formatting text in a

2003-10-10 Thread James Johnson
Hi,

More of a general HTML question, but thought I'd ask here:

I'm doing form validation and if something needs to be corrected, then the
user is informed and allowed to make changes. So, they don't have to retype
what they entered in the , I'm displaying it again with:



But, when the form is redisplayed, it is adding tab chars to the beginning
of the string. Is this a PHP issue or an HTML issue?

Suggestions?
Thanks,
James

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



[PHP] Echoing string with single quote from $_POST

2003-10-10 Thread James Johnson
Hi,

I'm building a form where a user can enter text. When the form is submitted
I'm doing some validation before continuing. If the form isn't filled
correctly, then the user has to correct it before continuing. However, I
want to save the data that has been entered (some of it may be lengthy), so
I'm doing this:



If the $_POSTed string has quotes in it, the output contains a slash

"It's great" becomes "It\'s great" on the page.

I've tried echo addslashes($_POST['adTitle']);} and that doesn't work. Is
there another function that will output the string just as it was input?

I've searched through the manual and haven't found anything yet. Just
thought you all would know off the top of your head(s). :)

Thanks,

James

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



RE: [PHP] Outside help

2003-10-08 Thread James Johnson
Ok, thanks for the input everyone. I've received several replies to this
message.

Thanks again,
James

-Original Message-
From: James Johnson [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 08, 2003 9:52 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Outside help


Hi,

Don't know if this an appropriate post, but am going to anyway.

I am up against a deadline, and have two pesky PHP situations that I can't
figure out. I'm sure that for the experts on this list, it would be easy,
and I could get if I had the time.

Would anyone be willing to contact me off-list to help out? I WILL make it
worth your time.

Thanks,

James

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

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



[PHP] Outside help

2003-10-08 Thread James Johnson
Hi,

Don't know if this an appropriate post, but am going to anyway.

I am up against a deadline, and have two pesky PHP situations that I can't
figure out. I'm sure that for the experts on this list, it would be easy,
and I could get if I had the time.

Would anyone be willing to contact me off-list to help out? I WILL make it
worth your time.

Thanks,

James

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



[PHP] Error catching script

2003-10-08 Thread James Johnson
Hello,

Is there a way, on a hosted server, to prevent PHP errors from showing in a
browser? Instead of "error whatever at line 107 in filename.php" to have it
redirect to a "Sorry, please report this error page"

Thanks,

James

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



RE: [PHP] Formatting a string for entry into MySQL

2003-09-23 Thread James Johnson
Ok, thanks. It took a little bit of experimenting with printf(), sprintf()
and quotes, but I got it to work.

mysql_select_db($database_CCB, $CCB);
$ad_contact = "[EMAIL PROTECTED]909-555-1212";
$esAdContact = mysql_escape_string($ad_contact);
$q = sprintf("UPDATE subscriber_ads SET ad_contact = '%s' WHERE subid = 43",
$esAdContact);
$r = mysql_query($q, $CCB) or print(mysql_error()); 

Thanks,
James

-Original Message-
From: Burhan Khalid [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 23, 2003 4:45 AM
To: James Johnson; [EMAIL PROTECTED]
Subject: Re: [PHP] Formatting a string for entry into MySQL


James Johnson wrote:
> Hi,
> 
> I'm trying to generate a string that contains a , to insert into a 
> MySQL table. It appears the  is being stripped out either just 
> before or during the update.

http://www.php.net/mysql-escape-string

-- 
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.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



[PHP] Formatting a string for entry into MySQL

2003-09-22 Thread James Johnson
Hi,

I'm trying to generate a string that contains a , to insert into a MySQL
table. It appears the  is being stripped out either just before or
during the update.

** code **
// has both info, update both
$ad_contact = $tr_email;
$ad_contact .= "";  
$pSep = "-";
$ad_contact .= $tr_p1AC;
$ad_contact .= $pSep;
$ad_contact .= $tr_p1PRE;
$ad_contact .= $pSep;
$ad_contact .= $tr_p1SUF;

// update the record
$qUpdate = "UPDATE subscriber_ads SET ad_contact = '$ad_contact' WHERE subid
= $sid"; print("$qUpdate"); $rUpdate = mysql_query($qUpdate, $CCB) or
die(mysql_error());

The print() statement shows the correct format in the browser. I've looked
at printf() and sprintf(), but can't quite figure the syntax.

I want the  in the string so it will output correctly in the browser
when that data is retrieved from the DB.

Suggestions?

Thanks,
James

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



RE: [PHP] Another code check

2003-09-18 Thread James Johnson
Hi John,

Thanks, that was it.

James

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



[PHP] Another code check

2003-09-18 Thread James Johnson
Hello,

Can anyone see what's wrong with the following code? It produces the
following in the browser:

Warning: Cannot add header information - headers already sent by (output
started at /home/.paco/campuscb/campuscorkboard.com/AdPay_MC.php:11) in
/home/.paco/campuscb/campuscorkboard.com/AdPay_MC.php on line 20

Which tells me that something is being written before the 
header("Location: " . "AdPayment_MCSuccess.php");

However, I can't figure out what it may be.

*** code starts at line 1 of page ***





Thanks,
James

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



RE: [PHP] Code check please

2003-09-17 Thread James Johnson
Hmm, ok I took out the 
$row_CampusIDList = mysql_fetch_assoc($CampusIDList); 

and it works But how come?

J

-Original Message-
From: James Johnson [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, September 17, 2003 9:17 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Code check please


Hi,

Can anyone see why this code isn't working

$SID = $_SESSION['svUserID'];
$AdID = $_GET['AdID'];

// get the campuses assigned
$qCampusID = "SELECT inst_id FROM ads_campuses WHERE ad_id = $AdID";
$CampusIDList = mysql_query($qCampusID, $CCB) or die(mysql_error());
$row_CampusIDList = mysql_fetch_assoc($CampusIDList);
//var_dump($row_CampusIDList);

$tmp = array();
while( $rowData = mysql_fetch_array( $CampusIDList )) {
//print("ROW Data $rowData");
if(!in_array($rowData['inst_id'],$tmp)){
  $tmp[] = $rowData['inst_id'];
 }
}
//var_dump($tmp);
$cidList = implode( ',', $tmp );
//var_dump($cidList);

If I do a var_dump($row_CampusIDList); I get a value, so I know there's data
to work with. But if I do a var_dump($tmp) and var_dump($cidList), they're
both empty.

This particular value query only has 1 inst_id of 100. Other queries with
one value (99,45, etc) will work.

Very strange...
Thanks,
James

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

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



[PHP] Code check please

2003-09-17 Thread James Johnson
Hi,

Can anyone see why this code isn't working

$SID = $_SESSION['svUserID'];
$AdID = $_GET['AdID'];

// get the campuses assigned
$qCampusID = "SELECT inst_id FROM ads_campuses WHERE ad_id = $AdID";
$CampusIDList = mysql_query($qCampusID, $CCB) or die(mysql_error());
$row_CampusIDList = mysql_fetch_assoc($CampusIDList);
//var_dump($row_CampusIDList);

$tmp = array();
while( $rowData = mysql_fetch_array( $CampusIDList )) {
//print("ROW Data $rowData");
if(!in_array($rowData['inst_id'],$tmp)){
  $tmp[] = $rowData['inst_id'];
 }
}
//var_dump($tmp);
$cidList = implode( ',', $tmp );
//var_dump($cidList);

If I do a var_dump($row_CampusIDList); I get a value, so I know there's data
to work with. But if I do a var_dump($tmp) and var_dump($cidList), they're
both empty.

This particular value query only has 1 inst_id of 100. Other queries with
one value (99,45, etc) will work.

Very strange...
Thanks,
James

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



[PHP] Repost - Cookie advice

2003-09-13 Thread James Johnson
Reposted, as it appears it didn't go thru.

Hi,

I have a "Remember me on this computer" check box, which sets a cookie for
future logins. What's the consensus on when a cookie of this type should
expire? I currently have it set for 30 days.

Thanks,
James

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



[PHP] Cookie advice

2003-09-12 Thread James Johnson
Hi,

I have a "Remember me on this computer" check box, which sets a cookie for
future logins. What's the consensus on when a cookie of this type should
expire? I currently have it set for 30 days.

Thanks,
James

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



[PHP] String formatting function - First char Upper, rest lower

2003-09-06 Thread James Johnson
Hi,

Newbie question.

Does anyone know of a function or script that will capitalize the first char
and lowercase the remaining chars of each word in a string?

Thanks,
James

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



[PHP] Unregistering several variables at once -- how?

2003-09-06 Thread James Johnson
Hi,

I have 15 - 20 $_SESSION vars that I want to clear when a user logs out.
I've been doing it with the following code:

if(session_is_registered($_SESSION['svUserID'])){
session_unregister($_SESSION['svUserID']);
}

But, this is tedious. Is there a better way, like session_unregister(all)?

Thanks,
James

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



[PHP] Help with copy()/uploading a file

2003-08-31 Thread James Johnson
Hi,

I need some help with the copy() function in order to allow a user to upload
an image. The image will need to be in a folder that I can access it's URL
for display in a page.

The hosting company, www.dreamhost.com, isn't too helpful with my requests
for help.

I have the following code:

$webServer ="/home/campuscb/ftp.campuscorkboard.com/adimages/";
$destFile = $webServer;
$destFile .= $img1_name;
if($img1_name!=""){
copy("$img1","$destFile") or die("Couldn't copy the file");
}
else{
die("No input file specified!$img1_name");
}

Dreamhost claims I must have Anon FTP activated in order to use the copy()
function. 
I went ahead and set Anon FTP setup on the server. According to the admin
panel, I have the following settings:

Path:/home/campuscb/ftp.campuscorkboard.com
Directory blocks are on except for Stor

When I run it, I get the following message in the browser:
Warning: open_basedir restriction in effect. File is in wrong directory in
/home/.paco/campuscb/campuscorkboard.com/upload.php on line 28 Couldn't copy
the file

Any help would be appreciated.

Thanks,
James

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



[PHP] PHP SESSION timeouts

2003-08-30 Thread James Johnson
Hi,

Can't find this in any of my books. Is there a default for when the
$_SESSION array times out i.e., it's no longer available for the code?

Thanks,
James

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



[PHP] RE: Solved. [PHP] Multiple word strings getting truncated - help please.

2003-08-30 Thread James Johnson
Hi David,

>From your suggestion, I found the problem. I'm validating the form and if
something isn't correct, I'm not doing the query, but maintaining what the
user previously entered with the following code:




In some of the input tags, I hadn't put quotes around the value.

Thanks,

James

-Original Message-
From: David Otton [mailto:[EMAIL PROTECTED] 
Sent: Saturday, August 30, 2003 3:24 PM
To: James Johnson
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Multiple word strings getting truncated - help please.


On Sat, 30 Aug 2003 14:52:30 -0700, you wrote:

>I have a form for a member to signup for an account. The form has 
>standard fields for addresses, city state, etc. When I insert the data 
>into the table, if the string has more than one word, it gets truncated 
>to the first word.
>
>Does this sound like a PHP or a MySQL problem.
>
>Here's the code: (partial as the query is quite long)

Odd. Try this

$tr_addr1 = mysql_escape_string ($_POST['addr1']);
$query = "INSERT INTO subscribers (addr1) VALUES('$tr_addr1')"; echo
("$query");

And tell us what you get. Then you at least know whether it's a MySQL
problem or an HTML/PHP problem.

Hmm. You are quoting your HTML attributes, right? That's the only thing I
can think of that even comes close to the behaviour you describe.

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

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



[PHP] Multiple word strings getting truncated - help please.

2003-08-30 Thread James Johnson
Hi,

I have a form for a member to signup for an account. The form has standard
fields for addresses, city state, etc. When I insert the data into the
table, if the string has more than one word, it gets truncated to the first
word.

Does this sound like a PHP or a MySQL problem.

Here's the code: (partial as the query is quite long)

$tr_addr1 = $_POST['addr1']
$query = "INSERT INTO subscribers (addr1) VALUES('$tr_addr1')";

The MySQl table is as such:

addr1 = varchar(50)

Thanks,
James

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



RE: [PHP] PHP equivalent to MOD

2003-08-30 Thread James Johnson
Nevermind, I found it in the archives.
Thanks

-Original Message-
From: James Johnson [mailto:[EMAIL PROTECTED] 
Sent: Saturday, August 30, 2003 12:25 PM
To: [EMAIL PROTECTED]
Subject: [PHP] PHP equivalent to MOD


Hi,

I need to see if a number is divisible by 2. I don't see the math function
"mod" in my PHP Functions reference manual. Is there another way to do this?

Thanks,
James

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

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



[PHP] PHP equivalent to MOD

2003-08-30 Thread James Johnson
Hi,

I need to see if a number is divisible by 2. I don't see the math function
"mod" in my PHP Functions reference manual. Is there another way to do this?

Thanks,
James

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



RE: [PHP] Looping through a list - Newbie question

2003-08-27 Thread James Johnson
I need to loop through a list that is generated by a  tag, so I can
query a lookup table. I managed to come up with this, 

");
}
?>

And have modified it to query the lookup table, then the main table. Seems
to work ok.

Thanks,
J

-Original Message-
From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 27, 2003 7:23 AM
To: James Johnson; [EMAIL PROTECTED]
Subject: Re: [PHP] Looping through a list - Newbie question


From: "James Johnson" <[EMAIL PROTECTED]>
> I have a list contained in a session var. I want to loop through the 
> list, getting the value of the current item, then do a query based on 
> that
value.
> Is there an easy way to do this, or do I need to convert the list to 
> an array first? In the code below, $id isn't being set.
>
> Here's my code (this is just testing stuff, sv_CampusList is set 
> somewhere
> else):
>  session_start();
> $_SESSION['sv_CampusList'] = "1,2,4,5";
> for($i=1; $i<=strlen($_SESSION['sv_CampusList']); $i++){
> $id = strpos($_SESSION['sv_CampusList'],$i);
> echo $id;
> }
> ?>

What are you actually trying to accomplish here? I could tell you how to
loop through a list in a string and run a query for each number, but I'd
have the horrible feeling that you're using some inefficient method to
accomplish something.

For instance, if you're just trying to select data matching the numbers in
your list, you can do this:

$query = "SELECT * FROM Table WHERE campus_list IN
({$_SESSION['sv_CampusList']})";

---John Holmes...

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



[PHP] Looping through a list - Newbie question

2003-08-27 Thread James Johnson
Hi,

I have a list contained in a session var. I want to loop through the list,
getting the value of the current item, then do a query based on that value.
Is there an easy way to do this, or do I need to convert the list to an
array first? In the code below, $id isn't being set.

Here's my code (this is just testing stuff, sv_CampusList is set somewhere
else):


Thanks,
James

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



RE: [PHP] Help with parse error

2003-08-20 Thread James Johnson
Yup, that was it. Missing a semi-colon on line 8.

Thanks,
James

-Original Message-
From: Peter James [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 20, 2003 1:17 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Help with parse error


Can you give us a couple lines either side of this?  This could be due
to a missing semicolon on the previous line.

--
Peter James
Editor-in-Chief, php|architect Magazine
[EMAIL PROTECTED]

php|architect
The Magazine for PHP Professionals
http://www.phparch.com


- Original Message - 
From: "James Johnson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 20, 2003 1:07 AM
Subject: [PHP] Help with parse error


> Hi,
>
> I'm trying to figure out this error I'm getting in my code:
>
> Parse error: parse error in /home/.paco/campuscb/AdPayment.php on line

> 9
>
> This is the code on line 9:
>
> $sDate = date('Y-m-d',time());
>
> Does this look valid?
> Thanks,
> James
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


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



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



[PHP] Help with parse error

2003-08-20 Thread James Johnson
Hi,

I'm trying to figure out this error I'm getting in my code:

Parse error: parse error in /home/.paco/campuscb/AdPayment.php on line 9

This is the code on line 9:

$sDate = date('Y-m-d',time());

Does this look valid?
Thanks,
James


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



[PHP] Problem with mktime, need to add 30 days to current date

2003-08-19 Thread James Johnson
Sorry about the previous post. 

Hi,

I need to make a date that is 30 days from the current date, and, am
having problems with mktime

Here's what I've tried:

$endDate=date('Y-m-d',mktime(0,0,0,date('m',time()),30,date('y',time()))
);

Return this: 2003-08-30

Is there an easy way to do this?

Thanks,
James


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



[PHP] Problem with mktime, need to add 30 days to current date

2003-08-19 Thread James Johnson
Hi,

I need to make a date that is 30 days from the current date, and, am
having problems with mktime

Here's what I've tried:


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



[PHP] Code formatting issue

2003-08-19 Thread James Johnson
Is there a way I can make this type of code neater?

$thing = new whatever ();

$thing->doStuff ();
$thing->anotherThing ();
$thing->doThis ();
$thing->doThat ();
$thing->doThis ();
$thing->doThat ();
$thing->anotherThing ();
$thing->doThis ();
// etc. etc.
Some languages have the construct "with", so you can so something like this:

$thing = new whatever ();

with ( $thing ) {

doStuff ();
anotherThing ();
doThis ();
doThat ();
doThis ();
doThat ();
anotherThing ();
doThis ();
// etc. etc.
}
which is much neater. Is there anyway to do this type of thing with PHP?

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


[PHP] Array to List

2003-08-14 Thread James Johnson
Hello,

Coming from ColdFusion, this is difficult. CF has an ArrayToList() function.
I can't find anything similar in PHP.

I'm building a list from an array with the following code, but it puts a
trailing "," and I need to remove it.

$campusList = "";
foreach ($_POST['campus'] as $campus_ID){
$campusList .= $campus_ID;
$campusList .= ",";
}
print($campusList);

I've tried this:
if($campusList <> ""){
$chr = ",";
$campusList = strrchr($campusList,$chr);
}

But it removes everything from the list, except 1 ","

Thanks,
James


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



RE: [PHP] Array to List

2003-08-14 Thread James Johnson
Actually, I'm using $campusList for a SQL statement:

SELECT name FROM campuses WHERE inst_id IN ('$campusList');

It wasn't working until I found out that $campusList needs to look like
'1','2','3'.

$campusList = implode( ', ', $_POST['campus'] );

Returns 4,2,3 (whatever was selected)

I've looked in the manual on implode, but don't see how to surround each
value with single quotes. Is there another function that will do this?

Thanks,
James

-Original Message-
From: Chris Boget [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 11, 2003 11:50 AM
To: James Johnson; [EMAIL PROTECTED]
Subject: Re: [PHP] Array to List


> Coming from ColdFusion, this is difficult. CF has an ArrayToList() 
> function. I can't find anything similar in PHP.

implode();

> I'm building a list from an array with the following code, but it puts 
> a trailing "," and I need to remove it.

[snip]

$campusList = implode( ', ', $_POST['campus'] );

Simple as that.
Read more about arrays here:

http://www.php.net/manual/en/ref.array.php

Chris



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



[PHP] PHP and quickcommerce.com

2003-08-14 Thread James Johnson
Hello,

Has anyone had experience dealing with quickcommerce.com? I'm  having some
problems submitting Credit Card info to them and could use some help.

Thanks,
James


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



RE: [PHP] Array to List

2003-08-14 Thread James Johnson
Ok, that's working. I realized tho that some campuses will have a "," in
their name (University of California, Riverside) so changed

$c = implode( ', ', $c );

To

$c = implode( '; ', $c );

Thanks,
James

-Original Message-
From: Chris Boget [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 11, 2003 1:42 PM
To: James Johnson; [EMAIL PROTECTED]
Subject: Re: [PHP] Array to List


Everything is fine in your script up to here:

> $row_GetCampuses = mysql_fetch_assoc($GetCampuses);

The above is getting just one (1) record from the database.  If you ever
have only one, you are good to go.

> $totalRows_GetCampuses = mysql_num_rows($GetCampuses);

I'm not sure what you are doing with this as I don't see it anywhere in your
included script.

> $c = implode( ', ', $row_GetCampuses );

And all this is doing is comma delimiting the values for each of the 
fields in your 'campuses' table.

This is what you want to do:




Campuses: 

Check out these sites:

PHPBuilder.com
webmonkey.com

Both have really good tutorials/resources dealing with both arrays and
working with data from databases.  You could use both, I would think.

Good luck!

Chris



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



[PHP] What does -> mean?

2003-08-14 Thread James Johnson
Hello,

I've searched through Zend and php.net and can't find the answer.

In the following code:

 $this->vendor = $vendor; 

What does the -> mean or do?

Thanks,
James


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



RE: [PHP] Array to List

2003-08-11 Thread James Johnson
John Holmes suggested that as well.

What I'm getting is this:

Campuses: Cal. State San Bernardino 

When I echo $c, I get:

Cal. State San Bernardino

Leading me to believe that the SQL query is wrong.

BTW, I saw I was using "SELECT *...", when all need is the name, so I
changed it to "SELECT name..."

James

-Original Message-
From: Jim Lucas [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 11, 2003 1:32 PM
To: James Johnson; [EMAIL PROTECTED]
Subject: Re: [PHP] Array to List


on page one do this instead.



Jim Lucas

- Original Message -
From: "James Johnson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, August 11, 2003 1:29 PM
Subject: RE: [PHP] Array to List


> All,
>
> Thanks for your help, but this shouldn't be so freaking hard to do. 
> 
>
> 1) I have a multiple select input on one page that is populated with a
list
> of campuses. The user selects which campus(es) to search on.
> 2) the user submits the form and goes to the next page.
> 3) I want a list of the selected campus(es) at the top of the page
>
> Page 1
>  user sees this 
> Select Campus(es)
> ---
> Cal State San Bernardino
> University of Redlands
> University of California, Riverside
> Universtiy of California, San Diego
> *
> -- code --
> 
>  if(isset($_POST['Submit'])){
> $_SESSION['sv_CampusList']= implode( ', ', $_POST['campus'] );
> header("Location: " . "search.php");
> exit;
> }
> ?>
>
> Page 2
> 
> 
>  $cList = $_SESSION['sv_CampusList']; mysql_select_db($database_CCB, 
> $CCB); $query_GetCampuses = "SELECT * FROM campuses WHERE inst_id IN
> ($cList) ORDER BY name ASC";
> $GetCampuses = mysql_query($query_GetCampuses, $CCB) or
> die(mysql_error());
> $row_GetCampuses = mysql_fetch_assoc($GetCampuses);
> $totalRows_GetCampuses = mysql_num_rows($GetCampuses);
> $c = implode( ', ', $row_GetCampuses );
> echo $c;
> ?>
>
> 
> Campuses: 
>
> * user is supposed to see this *
> Campuses: Cal State San Bernardino, University of Redlands
>
> I did check the MySQL table and inst_id is an integer. When playing 
> around with the Query in PhpMyAdmin, I found that I needed to surround 
> the values in the IN clause with single quotes.
>
> Perhaps I'm going about this the wrong way. Any advice or suggestions
would
> be appreciated.
> Thanks,
> James
> -Original Message-
> From: CPT John W. Holmes [mailto:[EMAIL PROTECTED]
> Sent: Monday, August 11, 2003 1:12 PM
> To: James Johnson; 'Chris Boget'; [EMAIL PROTECTED]
> Subject: Re: [PHP] Array to List
>
>
> From: "James Johnson" <[EMAIL PROTECTED]>
>
> > Actually, I'm using $campusList for a SQL statement:
> >
> > SELECT name FROM campuses WHERE inst_id IN ('$campusList');
> >
> > It wasn't working until I found out that $campusList needs to look 
> > like '1','2','3'.
> >
> > $campusList = implode( ', ', $_POST['campus'] );
> >
> > Returns 4,2,3 (whatever was selected)
> >
> > I've looked in the manual on implode, but don't see how to surround 
> > each value with single quotes. Is there another function that will 
> > do this?
>
> You don't need the quotes if the values are integers, but if you 
> insist...
>
> $campusList = "'" . implode("','",$_POST['campus']) . "'";
>
> The implode "pattern" is a single quote, comma, single quote, then
surround
> the whole implode result by single quotes to complete it.
>
> ---John Holmes...
>
>
>
> --
> 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] Array to List

2003-08-11 Thread James Johnson
All,

Thanks for your help, but this shouldn't be so freaking hard to do. 

1) I have a multiple select input on one page that is populated with a list
of campuses. The user selects which campus(es) to search on.
2) the user submits the form and goes to the next page.
3) I want a list of the selected campus(es) at the top of the page

Page 1
 user sees this 
Select Campus(es)
---
Cal State San Bernardino
University of Redlands
University of California, Riverside
Universtiy of California, San Diego
*
-- code --



Page 2





Campuses: 

* user is supposed to see this *
Campuses: Cal State San Bernardino, University of Redlands

I did check the MySQL table and inst_id is an integer. When playing around
with the Query in PhpMyAdmin, I found that I needed to surround the values
in the IN clause with single quotes.

Perhaps I'm going about this the wrong way. Any advice or suggestions would
be appreciated.
Thanks,
James
-Original Message-
From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 11, 2003 1:12 PM
To: James Johnson; 'Chris Boget'; [EMAIL PROTECTED]
Subject: Re: [PHP] Array to List


From: "James Johnson" <[EMAIL PROTECTED]>

> Actually, I'm using $campusList for a SQL statement:
>
> SELECT name FROM campuses WHERE inst_id IN ('$campusList');
>
> It wasn't working until I found out that $campusList needs to look 
> like '1','2','3'.
>
> $campusList = implode( ', ', $_POST['campus'] );
>
> Returns 4,2,3 (whatever was selected)
>
> I've looked in the manual on implode, but don't see how to surround 
> each value with single quotes. Is there another function that will do 
> this?

You don't need the quotes if the values are integers, but if you insist...

$campusList = "'" . implode("','",$_POST['campus']) . "'";

The implode "pattern" is a single quote, comma, single quote, then surround
the whole implode result by single quotes to complete it.

---John Holmes...



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



RE: [PHP] Array to List

2003-08-11 Thread James Johnson
Chris, thanks that works perfectly

-Original Message-
From: Chris Boget [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 11, 2003 11:50 AM
To: James Johnson; [EMAIL PROTECTED]
Subject: Re: [PHP] Array to List


> Coming from ColdFusion, this is difficult. CF has an ArrayToList() 
> function. I can't find anything similar in PHP.

implode();

> I'm building a list from an array with the following code, but it puts 
> a trailing "," and I need to remove it.

[snip]

$campusList = implode( ', ', $_POST['campus'] );

Simple as that.
Read more about arrays here:

http://www.php.net/manual/en/ref.array.php

Chris



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



[PHP] MySQL field data type for ISBN numbers

2003-08-10 Thread James Johnson
Hi,

Don't know if this is an OT or not.

I have a MySQL database for books. The ISBN field is set as varchar(15) and
I've put a test ISBN number in of 1--111-11. Can someone tell me why
this SQL query isn't working?

$ISBN = $_GET['isbn'];
$query = "SELECT * FROM book_details WHERE ISBN = '$ISBN'";

Since the field is a varchar, should wrapping the variable (1--111-11)
in single quotes work?

If I change the data in the table to 'abcd' and run this query

$ISBN = 'abcd';
$query = "SELECT * FROM book_details WHERE ISBN = '$ISBN'";

It works.

PHP Version 4.3.2
mysql-4.0.14b

Thanks,
James


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



RE: [PHP] Trouble with Session var

2003-08-02 Thread James Johnson
DOH! Nevermind, I mis-spelled session_start().

:(
-Original Message-
From: James Johnson [mailto:[EMAIL PROTECTED] 
Sent: Saturday, August 02, 2003 4:19 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Trouble with Session var


Hello,

This one has me stumped.

I'm setting a session var to a value returned from a query, then redirecting
to another page. I get the following error on the second page:

Notice: Undefined index: sv_adCatText 

On the page that sets the session var, I can do an echo of
$HTTP_SESSION_VARS['sv_adCatText'] and it prints the var fine. If I do a
var_dump($HTTP_SESSION_VARS); I can see all of the session vars, except this
one.

Is there a limit or something to the number of Session vars that can be
used? I've even tried setting a Session var called "foo" and that doesn't
work.

Thanks,
James

Here's the code:

First Page:



Second Page:




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



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



[PHP] Trouble with Session var

2003-08-02 Thread James Johnson
Hello,

This one has me stumped.

I'm setting a session var to a value returned from a query, then redirecting
to another page. I get the following error on the second page:

Notice: Undefined index: sv_adCatText 

On the page that sets the session var, I can do an echo of
$HTTP_SESSION_VARS['sv_adCatText'] and it prints the var fine. If I do a
var_dump($HTTP_SESSION_VARS); I can see all of the session vars, except this
one.

Is there a limit or something to the number of Session vars that can be
used? I've even tried setting a Session var called "foo" and that doesn't
work.

Thanks,
James

Here's the code:

First Page:



Second Page:




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



[PHP] Reloading page in frame after SQL Insert

2002-12-13 Thread James Johnson
Hi,

I'm building a frameset based app which displays a list of pages. The left hand frame 
contains a list of pages, the middle frame has a "New Page" page. After the new page 
information is inserted into the DB, how can I get the left hand frame to refresh 
itself, to show the new page.

It must be a combination of PHP and JavaScript?

Thanks,

Jim Johnson


[PHP] PHP Redirects

2002-12-12 Thread James Johnson
Hi,

In ColdFusion, I can redirect to another page with the tag . Is there an equivalent in PHP?

Thanks,

Jim Johnson


[PHP] Fw: [SMARTY] JavaScript / PHP syntax problems

2002-12-12 Thread James Johnson
My mistake for posting to the wrong list. Meant to go to php-general.

I've got it working now. There's an option in Dreamwever for escaping quotes
with % 's or not.

Jim
- Original Message -
From: "Hoffman, Geoffrey" <[EMAIL PROTECTED]>
To: "James Johnson" <[EMAIL PROTECTED]>
Sent: Thursday, December 12, 2002 10:20 AM
Subject: RE: [SMARTY] JavaScript / PHP syntax problems


> When you say it's not getting passed, what do you mean exactly? Forget
about
> the iframe for a sec - If you view source on the page, is it in the code
or
> not?
>
> Are you getting
> src="pgDetail.php?siteID=1"
> or
> src="pgDetail.php?siteID="
> ?
>
> Whats %22, a single or double quote? If so you only have 1 of them in the
> snippet you posted.
> Or is that a 'feature' of the listserv?
>
> You posted:
>
>
>
> -Original Message-
> From: James Johnson [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 12, 2002 11:09 AM
> To: [EMAIL PROTECTED]
> Subject: [SMARTY] JavaScript / PHP syntax problems
>
>
> Hi,
>
> I'm using Dreamweaver as my PHP editor. I'm building an app which uses
> IFRAMES to show different PHP pages. Dreamweaver has a behavior which sets
> the text of a layer to HTML code. This works fine, until I try to pass a
> variable to the PHP page which shows up in the IFRAME.
>
> Here is what I want to pass:
>
>  height="100%" scrolling="Auto" id="pgDetail" frameborder="0">
>
> This is what DW generates:
>
> onClick="MM_setTextOfLayer('holder','','%3Ciframe
> src=%22pgDetail.php?siteID=%22 name=%22pgDetail%22
> width=%22100%25%22 height=%22100%25%22 scrolling=%22Auto%22
> id=%22pgDetail%22 frameborder=%220%22%3E%3C/iframe%3E')"
>
> But the $siteID is not getting passed.
>
> Thanks,
>
> Jim Johnson
>
>


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




Re: [PHP] overview of current app frameworks

2002-12-12 Thread James Johnson
I'd also add Fusebox for PHP (www.fusebox.org,
http://sourceforge.net/projects/php-fusebox/) AND the "tone" of the user's
on the various mailing lists. The people on the PHP Fusebox list are
considerate and helpful. I made the mistake of posting a "newbie" PHP
question on the Smarty list and was amazed at the insolent messages that
we're sent back to me.

My $0.02.

Jim Johnson
- Original Message -
From: "Jonathan Ellis" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 11, 2002 1:29 PM
Subject: [PHP] overview of current app frameworks


> I recently checked up on just about every PHP application framework I
> could find.  I thought I'd throw my conclusions out for anyone else who
> was looking for something similar.
>


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




[PHP] Undefined Variable errors

2002-11-11 Thread James Johnson
Hello,

I'm migrating to PHP from ColdFusion.

I've been running some sample scripts I have found in various places and all
of them throw an error:

Notice: Undefined variable:  in
c:\inetpub\wwwroot\myphpcalendar\ on line .

In ColdFusion, I can use the  tag to preset a variable. I've tried
the following code to define the variable in PHP, but it doesn't work:

if (!isset($VarName)) {
$VarName = 0;
}

Is there a setting in php.ini or a call in the beginning of the script that
I need to use?

Thanks,

James Johnson
Owell Technologies
[EMAIL PROTECTED]



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




[PHP] test

2002-11-11 Thread James Johnson
test



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