RE: [PHP-DB] Can't do anything with variables

2003-04-06 Thread Luke Woollard
Dude - sweet book. I bought it myself when i was starting out.

Your problem is due to the PHP error message setting in the php.ini file.

Whack this at the beginning of your scripts:


// Report simple running errors
error_reporting  (E_ERROR | E_WARNING | E_PARSE);



When you know more - check out the php.ini file and read about the error
level..
And this page in the PHP manual:
http://www.php.net/manual/en/function.error-reporting.php

Cheers,

Luke Woollard





-Original Message-
From: Gilles [mailto:[EMAIL PROTECTED]
Sent: Monday, 7 April 2003 11:18 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Can't do anything with variables


Hi all,

Sorry for this really beginner question (PHP-Newbie here). I bought the book
PHP and MySQL web developpement (Welling  Thompson) and I'm trying to
recreate the exemples and it won't work. I installed PHP 4.3.1 and MySQL
4.0.12.

The easy part. Here's a simple form page (from the book):
SEARCH.HTML
html
head
  titleBook-O-Rama Catalog Search/title
/head

body
  h1Book-O-Rama Catalog Search/h1

  form action=results.php method=post
Choose Search Type:br
select name=searchtype
  option value=authorAuthor
  option value=titleTitle
  option value=isbnISBN
/select
br
Enter Search Term:br
input name=searchterm type=text
br
input type=submit value=Search
  /form
/body
/html

And now the processing page:
RESULTS.PHP
html
head
  titleBook-O-Rama Search Results/title
/head
body
h1Book-O-Rama Search Results/h1
?
  if (!$searchtype || !$searchterm)
  {
 echo You have not entered search details.  Please go back and try
again.;
 exit;
  }

  $searchtype = addslashes($searchtype);
  $searchterm = addslashes($searchterm);

  @ $db = mysql_pconnect(localhost, bookorama, bookorama);

  if (!$db)
  {
 echo Error: Could not connect to database.  Please try again later.;
 exit;
  }

  mysql_select_db(books);
  $query = select * from books where .$searchtype. like
'%.$searchterm.%';
  $result = mysql_query($query);

  $num_results = mysql_num_rows($result);

  echo pNumber of books found: .$num_results./p;

  for ($i=0; $i $num_results; $i++)
  {
 $row = mysql_fetch_array($result);
 echo pstrong.($i+1).. Title: ;
 echo stripslashes($row[title]);
 echo /strongbrAuthor: ;
 echo stripslashes($row[author]);
 echo brISBN: ;
 echo stripslashes($row[isbn]);
 echo brPrice: ;
 echo stripslashes($row[price]);
 echo /p;
  }

?

/body
/html

The problem. Even if I fill both fields, I always get Notice: Undefined
variable: searchtype

The only way it would work is if I remove all the if part and leave the
select * from books (without the where clause).

I don't get it. Any help would be much appreciated.

Regards

Gilles


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



RE: [PHP-DB] PHP and MySQL 4

2003-03-30 Thread Luke Woollard
Sure does - sure is.


-Original Message-
From: Benjamin Higgins [mailto:[EMAIL PROTECTED]
Sent: Monday, 31 March 2003 6:47 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] PHP and MySQL 4


Does PHP have support for MySQL 4?  If I install MySQL 4, and rebuild PHP
with --with-mysql, is that sufficient to get MySQL 4 support?

Ben



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



RE: [PHP-DB] Creating mySQL database

2003-03-18 Thread Luke Woollard
sure - just pass the mysql query through the mysql_query function.

Make sure you connect using mysql_pconnect() first, then you can start
creating databases..

Luke Woollard



-Original Message-
From: Thomas Tremain [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 19 March 2003 4:36 PM
To: '[EMAIL PROTECTED]'
Subject: [PHP-DB] Creating mySQL database



Can I create a mySQL user and PW from PHP


Thomas Tremain
www.LiveHost.net http://www.livehost.net/




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



RE: [PHP-DB] Re: Really easy question

2003-03-18 Thread Luke Woollard
$str = 'hi';
$newstr = eregi_replace(\, , $str);



-Original Message-
From: Peter Beckman [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 19 March 2003 4:33 PM
To: Foong
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Re: Really easy question


$str = 'hi';
$newstr = preg_replace(/\/, , $str);

On Wed, 19 Mar 2003, Foong wrote:

 try

 $with_quote = '0';
 $without_quote = str_replace('', '',  $with_quote);

 Foong


 Jeremy [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 Hey folks,
 Im apologize that this is just a really easy general php question but any
 help would be appreciated.

 if i have a variable that is = to something like 0 or 1

 but I just need it to be 0 or 1. how do i strip the  off.

 thanks,
 Jeremy



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


---
Peter Beckman  Internet Guy
[EMAIL PROTECTED] http://www.purplecow.com/
---

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



RE: [PHP-DB] Server Error

2003-03-17 Thread Luke Woollard
Your MySQL Database is down.

'cd' to your mysql directory (probably /usr/local/mysql ) and type
./bin/safe_mysqld --user=mysql 





-Original Message-
From: Marie Osypian [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 18 March 2003 8:42 AM
To: php-db
Subject: [PHP-DB] Server Error


I was able to access my database for weeks and now I am getting this error.
Can anyone help?


Warning: Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (2) in
/home/blah/public_html/includes/configi.inc.php on line 3

Warning: MySQL Connection Failed: Can't connect to local MySQL server
through socket '/var/lib/mysql/mysql.sock' (2) in
/home/blah/public_html/includes/configi.inc.php on line 3

Thanks,

Marie


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



RE: [PHP-DB] Server Error

2003-03-17 Thread Luke Woollard
This should read 'Your MySQL Database SERVER is down'

Thanks,

LW



-Original Message-
From: Luke Woollard [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 18 March 2003 8:48 AM
To: Marie Osypian; php-db
Subject: RE: [PHP-DB] Server Error


Your MySQL Database is down.

'cd' to your mysql directory (probably /usr/local/mysql ) and type
./bin/safe_mysqld --user=mysql 





-Original Message-
From: Marie Osypian [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 18 March 2003 8:42 AM
To: php-db
Subject: [PHP-DB] Server Error


I was able to access my database for weeks and now I am getting this error.
Can anyone help?


Warning: Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (2) in
/home/blah/public_html/includes/configi.inc.php on line 3

Warning: MySQL Connection Failed: Can't connect to local MySQL server
through socket '/var/lib/mysql/mysql.sock' (2) in
/home/blah/public_html/includes/configi.inc.php on line 3

Thanks,

Marie


--
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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] Picture Upload

2003-03-11 Thread Luke Woollard
Me either
Luke Woollard


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf
Of Fredrik de Vibe
Sent: Wednesday, 12 March 2003 12:51 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Picture Upload


[EMAIL PROTECTED] (Dallas Freeman) writes:
 I have asked my host to update the php software, as for now, I need to
 know what the lines for changing the size of a picture is.  I couldn't
 see any command lines for it, unless it is something different, I don't
 know, so could you please show me.

Afaicr, there is an excellent recipe for doing just that in The
Manual, under image functions.

 I also need to know, if there is a possibility that php can change the
 size of an image before it uploads it to the server (so it changes size
 on the end-user's computer  not on the server - that way there would be
 a shorter upload time).

PHP is server side, and can't do anything on the client side (apart
from reading and writing cookies, if the user allows it). I can't see
any other solution to this than to tell the users to resize the images
themselves.


-- 
--Fredrik
Reality is that which, when you stop believing in it, doesn't go
away.
-- Philip K. Dick

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



RE: [PHP-DB] Picture Upload

2003-03-10 Thread Luke Woollard
use the GD Library functions - look up on php.net

The GD library is available from http://www.boutell.com/
It is included by default with PHP 4.3.x

NOTE: This is a question for [EMAIL PROTECTED]


-Original Message-
From: Dallas Freeman [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 11 March 2003 5:07 PM
To: 
Subject: [PHP-DB] Picture Upload


Is there a possibility that you can resize an image before uploading to
the server?
 
If so, how?
 
Thanks,
 
 
Dallas Freeman


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



[PHP-DB] Auto Generation of HTML Forms + SQL Code to update My/Postgre SQL Database

2003-02-19 Thread Luke Woollard
Does anyone know of a program that can autp-generate HTML interfaces and PHP
Code to add to/update/delete from different tables in a mysql/postgresql
database?

Something similar to some of the RAD tools on the market for Microsoft
products etc...

I'm trying to quicken my development cycle.
:)

Luke Woollard


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




RE: [PHP-DB] Auto Generation of HTML Forms + SQL Code to update My/Postgre SQL Database

2003-02-19 Thread Luke Woollard
thanks dude.

-Original Message-
From: Jason Wong [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 20 February 2003 5:04 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Auto Generation of HTML Forms + SQL Code to update
My/Postgre SQL Database


On Thursday 20 February 2003 23:49, Luke Woollard wrote:
 Does anyone know of a program that can autp-generate HTML interfaces and
 PHP Code to add to/update/delete from different tables in a
 mysql/postgresql database?

 Something similar to some of the RAD tools on the market for Microsoft
 products etc...

 I'm trying to quicken my development cycle.

freshmeat.net and search for mysql forms

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
Nobody can be as agreeable as an uninvited guest.
*/


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




RE: [PHP-DB] how do I use same page for submit and results?

2003-02-06 Thread Luke Woollard
or you can use check for the name of the submit button using a specific
SUPERGLOBAL array.

e.g.

if ( ! empty($_POST[submit]) ) {
   /* form was submitted */
} else {
   /* form hasn't been submitted, show it */
   echo 'form name=something method=post'
.' form fields/button goes here '
.'input type=submit name=submit value=send form'
.'/form';
}


Best to check if a variable exists

Using the other method will throw an error: Notice: Undefined index: action
in c:\program files\apache group\apache\htdocs\testerr.php on line x...



Thanks,

Luke Woollard








-Original Message-
From: Joshua Stein [mailto:[EMAIL PROTECTED]]
Sent: Friday, 7 February 2003 5:29 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] how do I use same page for submit and results?


 But now I'm not using anything that I can check except for the
 button click. Any ideas how to do this?

assign a name to the button and check for that.

input type=submit name=action value=Show List

...

if ($_REQUEST[action] == Show List) {
   /* form was submitted */
   ...
} else {
   /* form hasn't been submitted, show it */
   ...
}


   -j.

--
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] PHP Database Abstraction Layer

2003-02-05 Thread Luke Woollard
I once read a great article in the first or second issue of
http://www.phparch.com/ on database abstraction layers. At which point I
used the tutorial as a starting point for creating a very similar structure
I named dbWave. There are only minor differences and a postgresql driver is
now included for the most common pg_* functions.

I was just wondering if anyone has developed a database abstraction layer
that allows you to separate your SQL queries from your application logic
like dbWave does? I'm looking for a more advanced way of doing this?


Attached is dbWave for anyone to look at/use. To run it you need to use the
following tags in your file:

// DBWave include files
include( [attached_filename].php );

To instantiate the dbWave object you use the following code in a file name
connect.php
?php

/* This file instantiates dbWave using our chosen API */
/* It is automatically generated by the database setup program */

// Instantiate dbWave using the MySQL API
$dbWave = new Mysql();

// Connect to the database
$dbWave-connect( 'yourhost', 'yourport', 'yourdbname', 'yourdbuser',
'yourdbpass' );
?


Thanks,

Luke Woollard
Programmer / Analyst
TABORVISION.com


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


RE: [PHP-DB] Using Objects with Databases

2003-01-21 Thread Luke Woollard
Initialise the database connection and perform actions on the database using
a seperate class.
You can pass your functions (methods) values returned from your database
calls to manipulate.

This is commonly called a 'database abstaction layer'

Theres a good database abstraction class in this magazine by a guy called
marco talbini http://www.phparch.com/

Else lookup PEAR:MB or adodb library on teoma.com or similar.





-Original Message-
From: Philip Zee [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 22 January 2003 4:27 PM
To:
Subject: [PHP-DB] Using Objects with Databases


Hello all,

I am trying to create a class, say User.  Each user has an entry in the
database
table called user.  Each function, including the constructor, will be
calling
the database to do something.  Is it better to initialize the database
connection inside each function or is it better to initialize the connection
at
the beginning of the class?  What's the best practice on this?

Any help or example is appreciated.

Thanks,

Philip


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




RE: [PHP-DB] Using Objects with Databases

2003-01-21 Thread Luke Woollard
I store all my sql queries in an include file.
These queries could store the actions you want to perform for each user..

I then use scripts to execute queries (with an alias name for each) based on
decisions (such as whether certain $_POST variables are present etc..)

If I were building a 'user' class - I would store the actions that would
'call' the appropriate query by it's alias. This allows other objects to
perform the same queries without re-writing them inside a different class.

Also - I'm using a database abstraction layer so I don't have database
specific calls inside my classes. This helps maintain portability of my
applications.

Hope that helps.

LW






-Original Message-
From: Philip Zee [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 22 January 2003 5:16 PM
To: Luke Woollard; PHP-db
Subject: RE: [PHP-DB] Using Objects with Databases


Luke,

Thanks for the help.  This only answers half of my question.  I understand
that
you need to build a class to handle your database needs.  However, once the
database returns a row in the table user, there will be functions
performed
for that user.  I was thinking about creating a class User to handle the
initialization and other functions for the user.  What's the best way of
doing
that?

Thanks,

Philip

-Original Message-
From: Luke Woollard [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 21, 2003 9:38 PM
To: PHP-db
Subject: RE: [PHP-DB] Using Objects with Databases


Initialise the database connection and perform actions on the database using
a seperate class.
You can pass your functions (methods) values returned from your database
calls to manipulate.

This is commonly called a 'database abstaction layer'

Theres a good database abstraction class in this magazine by a guy called
marco talbini http://www.phparch.com/

Else lookup PEAR:MB or adodb library on teoma.com or similar.





-Original Message-
From: Philip Zee [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 22 January 2003 4:27 PM
To:
Subject: [PHP-DB] Using Objects with Databases


Hello all,

I am trying to create a class, say User.  Each user has an entry in the
database
table called user.  Each function, including the constructor, will be
calling
the database to do something.  Is it better to initialize the database
connection inside each function or is it better to initialize the connection
at
the beginning of the class?  What's the best practice on this?

Any help or example is appreciated.

Thanks,

Philip


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




RE: [PHP-DB] Unlimited Categories

2003-01-13 Thread Luke Woollard
EG:

CREATE TABLE category (
id int not null auto_increment,
parent int default 0,
name varchar 100,
 );

The parent field contains the ID of the record of which category it belongs.

Then use a recursive function to display the 'levels' of data. (If parent is
0 then it is top level category)

Luke Woollard



-Original Message-
From: Gerard Samuel [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 14 January 2003 4:32 PM
To: php-db
Subject: [PHP-DB] Unlimited Categories


Im figuring this is more of an sql question than anything else.
I'm trying to figure out a table structure to create unlimited depths of
categorical data.
I've done something for category/subcategories before, but haven't an
idea how to create categories at an unlimited depth.

Any pointers would be greatly appreciated.
Thanks

--
Gerard Samuel
http://www.trini0.org:81/
http://dev.trini0.org:81/



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




RE: [PHP-DB] denying access to folders/files

2003-01-08 Thread Luke Woollard
I wrote a similar script a long time ago to achieve this. [Anti-Leech
solution]

You store the software in a folder that is outside of the web directory tree
and use PHP to 'fopen' the file being downloaded by the 'authenticated' user
and send it back to the broser using location() with the correct headers...

Here's a sample:
header(Content-Disposition: attachment; filename='thefilenamehere');
header(Content-type: application/octet-stream);
header(Content-Transfer-Encoding: binary);
header(Content-Length: .filesize('thefilename'));
header(Pragma: no-cache);
header(Expires: 0);
$fp=fopen(thefilename,r);
print fread($fp,filesize(thefilename));
fclose($fp);









-Original Message-
From: Darren Bentley [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 9 January 2003 11:20 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PHP-DB] denying access to folders/files


I'm hoping someone can give a little advise.

We have a customer that provides his software via a www address. We've
setup .htaccess on this folder with a single username/password. So he
supplies this user/pass to people that pay to get his software.

He now wants to have control over the username/passwords. He also wants
to have groups so that he can set which programs his customers can
download. He also wants it all logged.

I don't see this happening via .htaccess so I'm thinking of developing a
simple PHP/MYSQL interface.

So the customer comes to a login page, authenticates to a MYSQL
database, is assigned a cookie and is allowed access to which ever
programs his group allows.

This is fine and dandy, but how do I prevent that person from taking the
direct link to the file and giving it to someone else?

I'm sure there is a much better and simpler way. Idea's?

Thanks in advance.

--
Darren Bentley [EMAIL PROTECTED]


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




RE: [PHP-DB] Re: blob

2003-01-07 Thread Luke Woollard
I agree with Dave. I wrote an application to allow a client to upload/manage
images and categorise them into diff. parts of their website.

Images were stored as normal image files after upload and a pointer made to
them from the appropriate database record (which had additional image info
e.g. description)

Since I now have to move this website to a new server - transferring all
these files was a bit annoying. Storing them as binary data in mysql would
have been easier to manage...






-Original Message-
From: David Smith [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 8 January 2003 10:19 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Re: blob


On Tue, 2003-01-07 at 15:52, [EMAIL PROTECTED] wrote:

 I agree with this method.  i have not yet seen an advantage of storing
 blobs in a database.  Is there one?  i'm sure those on this list would
have
 an opinion if there was one.  personally, i like storing all this stuff on
 the file system.

There is one advantage. You must either chown the upload directory to
the user that your web-server runs as, or chmod it to be world-writable.
When creating a web-application that you plan to distribute (like
Slashcode), you can't assume that your users will have that privilege.
So, storing it in MySQL is a great option.

--Dave


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