[PHP-DB] php5 coding class objects best practices

2006-11-16 Thread Chris Barnes

hi people,
i havent used thi slist for quite a while.

anyway. Im trying to write an application which relies heavily on mysql. so
i have made a class object which has all the functions to make using mysql
very easy for me.

but the problem im faced with now is, i have a bunch of other classes, which
have a dependency to be able to read or write to mysql at some point.

i dont want to have to write and maintain seperate mysql classes to extend
other other classes.

is it alright to, for example, point to one class from within another?

e.g.

$user = new User();

$user-mysql = new MySql();

and then call functions in MySql() from within User() by;

$this-mysql-fetch_result_into_array();

im new to PHP5 so im not aware of all its new and awesome OO features.

does anyone have any advise?


[PHP-DB] net cafe software

2002-12-20 Thread Chris Barnes
Hi,
I'm looking for some net cafe style software written in PHP, which would
preferably use MySQL if it must use a database, which can track the data
each client downloads instead of tracking the amout of time the client
is online. Ideally the software would distinguish one client from
another by each machines unique MAC address...this way people cant
easily reconfigure their machine to get around the billing system. And
it would be good if the system had a way to alter the firewall to
dissallow specific clients mac address who havn't paid their bill or if
they account limit is reached.

I know i'm asking for a bit but if there's something close to that
written in PHP i should be able to alter it to do what i need, but i
haven't found anything on the net searching google.com, freshmeat.net,
nor sourceforge.net so i'm hoping one of you have seen/used something
similar.

Thanks very much :)





signature.asc
Description: This is a digitally signed message part


Re: [PHP-DB] Theory help needed

2002-12-20 Thread Chris Barnes
i'm not experienced so this is just a theory.

if you have a parent id field in your tables then each reply would have
the parent id of the original message they replied to, so when your
program gets the data it will get the original message, and then get any
other messages with the same parent id, then it would move on and get
the next original message...etc.

e.g.
to get original message:

select message_body,message_id from message_table

then to get the threads of the original message:

select message_body,message_id from message_table where
parent_id=[message_id of original message]

i know thats a vague description but its an idea...i guess..


On Fri, 2002-12-20 at 15:23, Chris Payne wrote:
 Hi there everyone,
 
 I have a messageboard which works, but what I need is some kind of threading for it. 
 Right now I have EXTREMELY basic threading, where you can reply to a message, reply 
to replies etc . and they'll appear in the correct part of the messageboard.  
What I need though is to be able to do proper threading, where each reply appears 
under the original message and not all over the place, but i'm confused as hell.
 
 Anyway have any experience with this kind of thing and can give me a push in the 
right direction?  I know I need to store the original ID, the forum ID, the message 
ID of the current message and the ID it relates to, but it's getting confusing :-)
 
 Thanks.
 
 Chris




signature.asc
Description: This is a digitally signed message part


RE: [PHP-DB] php session

2002-12-01 Thread Chris Barnes
On Mon, 2002-12-02 at 02:43, John W. Holmes wrote:
 
 No, it shouldn't.
 
 So, the links are correct on one page, and they disappear on the second
 page? Is there a reason you're passing the SID in the URL and not using
 cookies? 
 
 Hmmm, found this in the manual. Maybe it applies?
 
 ---
 The constant SID can also be used to retrieve the current name and
 session id as a string suitable for adding to URLs. Note that SID is
 only defined if the client didn't sent the right cookie. See also
 Session handling. 
 ---
 
 You may have to call session_id() with the passed value of
 $_GET['PHPSESSID'] so that PHP knows what session to restart. 
 
 ---John Holmes...
 

The reason I'm not using cookies is because i don't really know enough
about them yet (i don't really know enough about sessions either :p). Do
you think it would be better for me to generate my own unique number and
set that in the cookie? Will i have to keep calling SetCookie() on every
page?

One thing i should have mentioned in my previous email, even though it
isn't that relevant i don't think, is that if i omit the SID constant
from the URL string then PHP automatically appends the SID to the URL
its self, but again it disappears after a link has been clicked.




signature.asc
Description: This is a digitally signed message part


[PHP-DB] php session

2002-11-30 Thread Chris Barnes
hi people,
I'm having a little trouble getting sessions to work properly with php.
I have put session_start(); on all pages before any data is printed. The
session will start on the first loading of the page but after a link is
clicked the session seems to die i have no idea why.

for the links on the pages i have included the SID constant like so:
a href='index.php . SID . action=whatever'Link/a but after a link
is clicked the links them appear to lose the reference to the SID
constant so instead of looking like

a href='index.php?PHPSESS=s8743vbkuwivn7action=whateverLink/a

they look like

a href='index.php?action=whatever'Link/a

the session_start(); isn't right at the start of the pages, its a few
lines after but none of the lines before session_start(); print any
data, they only store data in variables...does that matter??

I'm completely stumped trying to get this to work properly.

can anyone offer any suggestions?
Thanks heaps.





signature.asc
Description: This is a digitally signed message part


[PHP-DB] error 1100

2002-11-25 Thread Chris Barnes
Hi people,
I dont know why but am stuck trying to debug this problem. I keep
getting error number 1100 (Table 'jobs' was not locked with LOCK TABLES)
from PHP when i try querying a mysql database. It has me stumped because
I am using the LOCK TABLES statement when locking the tables...but maybe
there is something wrong with my code that i cant see...


Here is the function i use to lock/unlock the table(s). I call this
function before querying the database. $dblink is the MySQL Link
Resource, $table is the table to lock, $grant describes how it should be
locked (READ/WRITE), if $table or $grant are null then it assumes the
tables are to be unlocked:

function lock($dblink,$table,$grant){
//function to lock/unlock tables

if(($table == null) or ($grant == null)){

$unlock = @mysql_query(UNLOCK TABLES,$dblink);

return  $unlock;
}

else{

$lock = @mysql_query(LOCK TABLES  . $table .   . $grant,$dblink);

return $lock;
}
}


Any ideas?
Thanks heaps :)



signature.asc
Description: This is a digitally signed message part


RE: [PHP-DB] LIKE statement or IN statement?

2002-11-03 Thread Chris Barnes
Yeah I really need to search for multiple words. Can anyone confirm if
the IN statement will work for me in this situation?

On Mon, 2002-11-04 at 09:31, [EMAIL PROTECTED] wrote:
 if you want to search for multiple words, u have to use multiple like
 operators:
 select count(distinct itemid) from business where name like 'word1' or
 name like 'word2' or name like 'word3';
 
  or the IN statement with wildcards:
 select count(distinct itemid) from business where name IN
 ('%word1%','%word2%','%word3%');  -- im not too sure of this, would the
 experts please shed some more light on this one if its correct?
 
 Amit
 
 On 4 Nov 2002, Chris Barnes wrote:
 
  Hi,
  I've got a dilly of a problem. I'm probably doing something wrong but
 I
  don't know what. I'm trying to use the LIKE statement in a query where
  more than one word is used in with LIKE..e.g.
 
  select count(distinct itemid) from business where name or description
  like 'word1 word2 word3%'
 
  The problem I'm having is probably obvious to you but I don't know why
  this returns no matches but if i specify only 1 word in the LIKE
  statement then it returns a match.
 
  Am i not able to specify more than 1 word with LIKE or am I just doing
  it wrong?
 
  It has been designed to take input from a web form by the variable
  $search_string and then the query string is constructed from that e.g.
 
  $query = select count(distinct itemid) from business where name or
  description like' . $search_string . ';
 
 
  Any help or suggestions greatly appreciated.
 
 
 
 ---
 Peter BeckmanSystems Engineer, Fairfax Cable Access
 Corporation
 [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
 




signature.asc
Description: This is a digitally signed message part


RE: [PHP-DB] PHP in Database Fields..

2002-06-25 Thread Chris Barnes

eval() might do what your asking for.
I'm no expert tho.

-Original Message-
From: Matthew Tedder [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 25 June 2002 7:32 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] PHP in Database Fields..



Question:

I want to put PHP code into database fields holding HTML text, how can I
make it execute that PHP before sending to the browser??

Currently, I get the text from MySQL and print it The browser shows
the PHP code mixed into the HTML.

Matthew


--
Anything that can be logically explained, can be programmed.

--
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] Problem w/ mysql_pconnect

2002-06-23 Thread Chris Barnes

Hi Paul,
I'm no MySQL expert and i'm only very new to this list but i have had the
same problem before.
What i did to fix the problem was replace localhost with the ip address of
the machine...so on my network i my MySQL server is 10.3.2.1 so i used
10.3.2.1 instead of localhost and it worked for me.

the real solution i guess would be to grant access for that username from
the localhost.localdomain address in your MySQL server.

see how u go.

-Original Message-
From: Paul D [mailto:[EMAIL PROTECTED]]
Sent: Monday, 24 June 2002 12:07 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Problem w/ mysql_pconnect


I'm using PHP 4.2.0 with MYSQL 3.23. When I try to use either the
mysql_connect or mysql_pconnect to access the database, I get the
following error message:

Access denied for user: '[EMAIL PROTECTED]' (Using password: YES)

I have tried different user names and nothing seems to work. If I use
the functions without any parameters, it'll work just fine, and when I
try access directly from the console, it'll work fine also. The problem
seems to lie with the function parameters, which is written as follows:

  $db = mysql_pconnect(localhost, pauld, any_pwd) or
die($php_errormsg);

Any suggestions would be very much appreciated.


--
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] question from newbie

2002-06-23 Thread Chris Barnes

Hi people,
Im quite new to the list.

I am trying to construct a php script that will take a string submitted from
a web site, break it up into keywords and add to an array, then perform a
query to a mysql db for each keyword in the array. It will then send the
result to the browser.

the script is complete so far as I have added the functions to get the
string from the web site, explode it and add it to an array, but i'm having
trouble putting together a loop that will do a new query for every keyword
in the array.

is anyone able to help me with an example of a loop which could work for me?

any help very much apreciated :)

Chris Barnes


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




RE: [PHP-DB] Question

2002-06-23 Thread Chris Barnes

i dont know how will this will work, but you could try storing the multiple
hard disk details for each computer in an array in 1 field.
then when you want to get the information from the db, use explode() to
store the value in the field into an array again.

e.g.
the field in the DB might look like this...
HardDriveSize = 1.2Gb,25Gb,25Gb

so get the field from the db and then use explode() to store it in an array
in php.
e.g.
$disk_size = explode(, , $field);

i dont know how well this will work for you...i'm only a newbie.


-Original Message-
From: Mike Tuller [mailto:[EMAIL PROTECTED]]
Sent: Monday, 24 June 2002 3:43 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Question


I am wanting to create a PHP frontend to a database that holds information
about the computers that I take care of. I have a problem though when it
comes to storing hard drive information. In most cases, the computers have
one drive, but some have 2 or more, so I can't create the main database with
fields like this.

ComputerID
HardDriveType
HardDriveSize

I know I will need to create a separate table to hold information about the
drives, and connect them to the computer by attaching the primary key of the
drives table to the Computer table.

Computer Table

ComputerID
DriveID

Drive Table

DriveID
HardDriveType
HardDriveSize

This is where I am unsure. If there is more than one drive, then this would
be incomplete because it would only show one drive. What is the best way to
make it so that all drives show for the computer, or am I doing this
backwards? Should I tie the computer to the drive instead?

Thanks,
Mike


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