[PHP-DB] mysql_fetch_array and extract() with LEFT SELECT

2003-02-19 Thread Baumgartner Jeffrey
I'm having a problem when I use mysql_fetch_array and extract() following a
left select query. As an example...

$query = SELECT id,LEFT(fluff,80) FROM sometable;
$result = mysql_query($query) or die('message');

while ($row = mysql_fetch_array($result){
extract($row);
echo P . $id . :  . $fluff . /P;
}

would echo the $id, but there would be nothing for $fluff. However, if I
select only 'fluff' from the MySQL table, I get the full text for $fluff. I
am reluctant to SELECT the entire fluff text from the table and shorten it
in PHP  as that seems inefficient to me - (but correct me if I am wrong).

I expect the solution must be dead easy, but I can't find it or figure it
out.

Many thanks,

Jeffrey

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




[PHP-DB] Session variables when global variables switched off

2003-02-18 Thread Baumgartner Jeffrey
I am making a section on a web site which requires that visitors log-in.
Log-in, password, etc are in an MySQL table. I am using (via a web host) PHP
4.2.2 with global variables turned off. Until now, I have worked with a
different host in which global variables were switched on.

The way it works
The user logs in at index.php. When she does so successfully, index.php
returns a menu of links. However, if she clicks on any of those links, which
are different pages, she gets a please log-in first message 




eBusiness Consultant - ITP Europe
http://www.itp-europe.com
[EMAIL PROTECTED]
+32 2 721 51 00


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




[PHP-DB] Session variables when global variables switched off [Sorry, first message accidentally fired off to quickly ]

2003-02-18 Thread Baumgartner Jeffrey
[sorry for the incomplete posting of a couple moments ago. I hit ctl
something or other and outlook fired off the e-mail against my wishes!]

I am making a section on a web site which requires that visitors log-in.
Log-in, password, etc are in an MySQL table. I am using (via a web host) PHP
4.2.2 with global variables turned off. Until now, I have worked with a
different host in which global variables were switched on.

The way it works
The user logs in at index.php. When she does so successfully, index.php
returns a menu of links. However, if she clicks on any of those links, which
are different pages, she gets a please log-in first message because each
page includes...

if ($_SESSION['verified']  yes){
echo Pa href='index.php'Please log in first/a/P;
exit();
}

Returning to index.php requires a log-in again.

So, it seems the session variable is not being sent being sent between
pages, although it works within the same page. I expect I am missing
something obvious. I've made this kind of thing work with global variables
on - so I assume I am misunderstanding something related to lack of global
variables. 

I use 

session_start(); 

at the top of all pages and  

session_register($_SESSION['okbabe']); 

on index.php.

Your enlightenment will be highly appreciated.

Jeffrey Baumgartner


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




RE: [PHP-DB] collaborating on a document

2003-02-12 Thread Baumgartner Jeffrey
  1-Since he's posting to a PHP-DB list, I think we can assume he plans
  to implement it in PHP using a database to capture and store the
  comments/ideas. 
 
 Correct, thank you.
 
  Jeff - Do you have a plan in place for your DB schema or the backend
  processing that might take place?
 
 No, I'm still at the thinking stage. Since I'm new to PHP + databases, I
 was hoping to get expert feedback at the earliest stage, rather than
 discovering too late that my idea wasn't the best approach. 
 
 

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




[PHP-DB] collaborating on a document

2003-02-11 Thread Baumgartner Jeffrey
I'm thinking about making a little tool where people can contribute ideas in
real time. Thus far, the best way I can see to do this is via 2 frames

Frame 1: for entering data - which is inserted into a table. 

Frame 2: would select from the table.  It would also refresh frequently -
say every 30 seconds.

But perhaps you have a more elegant solution?

Thanks,

Jeffrey Baumgartner

eBusiness Consultant - ITP Europe
http://www.itp-europe.com
[EMAIL PROTECTED]
+32 2 721 51 00


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




RE: [PHP-DB] Members area

2003-01-23 Thread Baumgartner Jeffrey
I'm working on a similar project - I'm also a newbie - here's my approach -
which is fairly simple really.

Create a database of all members that includes columns for login, name
and paymentStatus as well as any other info you need for your database.
paymentStatus would be an integer with values of 2 and 5 initially (this
allows room for the creation of other levels in the future) in which 2 is
for paid members and 5 is for free members.

Once members log-in, their paid status is saved as a session variable:
$paymentStatus. 

All member-area pages will start with session_start(); at the beginning and
a check of the value of $paymentStatus. If it is null, they are sent to the
log-in page. If the page is for members only, then the value of
$paymentStatus must be =2. If it is for any member, then $paymentStatus
will have to be =5 (this all gives room for different levels of membership
in the future, you see).

Likewise content, which is stored on tables, includes a $paid variable which
indicates who is able to view it. This way, you can deliver dynamic content,
links and other information according to the $paymentStatus value of each
visiting member. In my case, I will have index pages with links to content
pages. All links will be visible, but links for paid members will be clearly
indicated. The purpose of this is to show freeloaders what they are missing!

I hope this is clear. More experienced members of this list may well find
flaws with my method.

Good luck,

Jeffrey Baumgartner

eBusiness Consultant - ITP Europe
http://www.itp-europe.com
[EMAIL PROTECTED]
+32 2 721 51 00

 -Original Message-
 From: Gavin Amm [SMTP:[EMAIL PROTECTED]]
 Sent: Thursday, January 23, 2003 2:03 AM
 To:   [EMAIL PROTECTED]
 Subject:  [PHP-DB] Members area
 
 Hi All,
 
 I'm about to start development on a members area for a site.
 The members area will have 2 levels - Paid  Free, with the Paid members
 having access to more pages.
 
 I have not created a members area before  am after any advice or links
 I can get... I think a lot of reading is in order...
 
 Particularly:
 - DB structure  fields (I'll be using MySQL if that's relevant)
 - Sessions (I've seen quite a few threads covering sessions over the
 last couple of months, so should have some links in my 'inbox'
 somewhere... But the more the merrier...)
 - Any PHP suggestions/advice/links
 - Anything else you can think is relevant...
 
 
 Thanks, this will be a big help.
 
 Cheers,
 Gav
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

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




[PHP-DB] Data won't insert

2003-01-23 Thread Baumgartner Jeffrey
I've learned the basics of PHP and MySQL by using a web hosting service over
the past few weeks. Call this site 1. And I am finally feeling that I am
getting the hang of things. 

Now, another web host that I have been using is letting me try out PHP and
MySQL on their server. Call this site 2.

The problem I am having is that if I take pages with php scripts from site
1; change the user, password and database names; and upload them to site 2 -
data does not insert into tables. However, the scripts are connecting to the
database (no die messages or other error messages are appearing) and the
tables have been prepared via phpmyadmin without problem. Likewise, I can
insert data via phpmyadmin without problem. 

Below is a sample script that is causing such a problem. I appreciate that
it is sloppy (it was one of my first). But it works on site 1 and not site
2.  Could this be a matter of the permissions the site 2 web host has
granted me? And if so, why can I do things with phpmyadmin but not via my
own scripts?

Many thanks,

Jeffrey Baumgartner


?php
$dbcnx = mysql_connect(localhost, USER, PASSWORD);

$db = mysql_select_db(TABLENAME, $dbcnx) or die(Couldn't get DB);

If (isset($name)) {
echo P . $name . /p P . $age . /p;  
}

?

FORM ACTION=?php echo($PHP_SELF);  ? METHOD=POST
P Name: INPUT TYPE=TEXT NAME=name SIZE=62/p
P Age: INPUT TYPE=TEXT NAME=age SIZE=8/p
INPUT TYPE=SUBMIT NAME=submitInfo VALUE=Submit

?php

if (isset($name))  {
$query = INSERT INTO formtest (name,age) VALUES ('$name' , '$age') ; 

if (mysql_query($query)){
echo P . $name . /p P . $age . /p;  
}

else {
echo (pTough cookies, sunshine/p);
exit();
}
}


?

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




[PHP-DB] Efficiency

2003-01-21 Thread Baumgartner Jeffrey
A couple of questions of efficiency, please:

1. If I am creating a web page with numerous PHP calls to an MySQL database
is it more efficient to have lots of small blocks of php in an html page or
is it better to have just one or two big blocks of PHP with the html code
being delivered via echo statements?

2. If I want to know how many rows there are in a MySQL table, I can either
use the count function in MySQL (although I am having trouble figuring out
how to capture that value in a variable) or I can do a general select *
from from command in MySQL and then use the mysql_num_rows function in PHP
to get a row count (which is dead easy). It SEEMS to me the former would be
more efficient. Am I correct? 

Many thanks! 

Jeffrey Baumgartner

eBusiness Consultant - ITP Europe
http://www.itp-europe.com
[EMAIL PROTECTED]
+32 2 721 51 00


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




[PHP-DB] Mail() and replies

2003-01-15 Thread Baumgartner Jeffrey
Is there any way to receive mail via PHP? 

What I am interested in doing is creating a double opt-in e-mail list
whereby someone can subscribe to an e-mail service via an on-line form. Upon
doing so, they would get a confirmation e-mail. Replying to this e-mail
would confirm the subscription and add the sender's e-mail address to the
database (MySQL). 

Doable?

Thanks,

Jeffrey Baumgartner

eBusiness Consultant - ITP Europe
http://www.itp-europe.com
[EMAIL PROTECTED]
+32 2 721 51 00


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




[PHP-DB] Newbie q: problem with mysql_connect() on hosted service

2002-12-27 Thread Baumgartner Jeffrey
Sorry to bother you experts with a simple question (well, two actually).

I'm new to PHP and mysql. I'm using a hosted service (so I don't have access
to configuration files, server, etc). Recently, the server crashed. Since
resurrecting, all files attempting to connect to MySQL using 

$dbcnx = mysql_connect(localhost, [user], [password);

result in an error like:

Fatal error: Call to undefined function: mysql_connect() in
/home/.sites/22/site13/web/werks/formtest2.php on line 8

Prior to the crash, there was no problem.

After a string of questions to support, they finally admitted they don't
know PHP well enough to help me (!?!). However, they did install phpMyAdmin
- which seems to work okay. So, I'm not sure if I am doing something
fundamentally stupid or if the web host (Easyhost) has not configured things
correctly. Any suggestions will be most welcome.

On a related issue, I am completely fed up with Easyhost and am looking for
another web host. They should obviously be able to provide PHP + MySQL
together with decent support (very important). Ideally, they should provide
scalable service (from shared hosting to dedicated and be EU located (but
this isn't critical). They must be willing to host adult content (soft-core
erotica and adult humour). Any recommendations (on or off-list will be much
appreciated).

A million thanks,

Jeffrey Baumgartner


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