Re: [PHP-DB] Re: Another newbie question -- ANSWERED!!

2004-09-07 Thread Greg Donald
On Tue, 2004-09-07 at 12:16, Pete Holsberg wrote:
> Also, should I have back tics around a column name
> EVERYWHERE it's used in a SELECT (in this case, following
> ORDER)?

Only if you plan to use keywords as field names, otherwise it's
pointless.


-- 
Greg Donald

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



Re: [PHP-DB] IP-Banning

2004-08-23 Thread Greg Donald

On Mon, 2004-08-23 at 11:24, Daniel Schierbeck wrote: 
> Hi there,
> I'm writing a script that'll enable me to ban certain IP-addresses from 
> a site, and i have a qouple of questions:
> 
> 1.When inserting the IP into the database (probably MySQL), should
>   i use the dotted- or the long-type?

ip2long() and long2ip() are useful in reducing the amount of data you
must store.  If you use those PHP functions a 15 char ip address string
can be stored as a 4 byte signed int in MySQL, a savings of up to 11
bytes per address.  Postgres has native types for IPs however.

> 2.What is the best way to ban IP ranges?

There are several packages in PEAR for use with IPs:
http://pear.php.net/packages.php?catpid=16&catname=Networking


-- 
Greg Donald

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



Re: [PHP-DB] Differences between two mySQL Databases

2002-06-25 Thread Greg Donald

On Tue, 25 Jun 2002, Michael Robbins wrote:

>I'm looking for a utility that can compare two database structures and
>generate a SQL statement that will duplicate the differences.
> 
>I'm using mySQL and I have both live and development databases.  While
>working on the development database, I frequently make changes to table
>structures, adding/removing tables or columns, changing column types, or
>adding/removing indexes.  
> 
>When I'm ready to move my changes to the live site, I'd like to just
>compare the two databases, and have it generate a SQL statement that I
>can run on my live database, so that it's structure will match my
>development database.  This would be much easier than trying to make all
>of the changes manually, or writing my own script to make the changes
>(how would you test this? Can't test it on the development database, the
>changes are already there.  Can't test it on the live database, what if
>there's a mistake of some kind?)

Do a diff on the two tables descriptions.

mysql -uuser -ppass database1 -e 'desc sometable' > sometable1 &&
mysql -uuser -ppass database2 -e 'desc sometable' > sometable2 && 
diff sometable1 sometable2 > difference

cat difference


-- 
---
Greg Donald
http://destiney.com/public.key
---



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




Re: [PHP-DB] WHERE clause

2002-03-03 Thread Greg Donald

On Sun, 3 Mar 2002, Jennifer Downey wrote:

>Wondering do I have to have the WHERE clause in a select query?
>
>$b=mysql_query( SELECT * FROM my_table) <-can I use something like this
>or do I have to put WHERE in the statement?

The where clause is optional.

-- 
-------
Greg Donald - http://destiney.com/
http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/
---



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




Re: [PHP-DB] Tutorial?

2002-03-03 Thread Greg Donald

On Sat, 2 Mar 2002, Jennifer Downey wrote:

>Can anyone point me to a good tutorial on how to disable a submit button
>once clicked?
>preferably in php.

If you reload the page after the button is clicked then you can simply
pass a $disable variable in your form as a hidden field, then you can
check for the variable before drawing the button the second time.

Sounds more like a javascript thing to me though.  PHP is a server side
scripting language, it's not designed to manipulate forms and buttons,
where javascript is.

-- 
-------
Greg Donald - http://destiney.com/
http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/
---



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




Re: [PHP-DB] I cant get the logic for this...

2002-02-18 Thread Greg Donald


> I want to display return results from my query (which works fine)
> In I tidy way on screen.
>
> So my result returns say seven results, I have a table, and I want to
> show
> 3 results per row of the table... I.e.:
>
> Table
> TR
> TD = result1 /TD  TD result2 /TD TD = result3 /TD
> /TD
> /TR
> TR
> TD = result4 /TD  TD result5 /TD TD = result6 /TD
> /TD
> /TR
> TR
> TD = result7 /TD  TD resultempty /TD TD = resultempty /TD
> /TD
> /TR
> /table
>
> The last two td in row 3 are empty because result found 7 results.
>
> This cant be fixed so echo statements wont work as the result could
> Be 3 or 10 or 56 or whatever.
>
> As Always your help and or guidance in this matter is appreciated.

You need a incrementer variable so you can tell when you have 3  cells
built, so you know when to end the current  and start a new one.

Then, you need to test that variable again when you run out of
mysql_num_rows(), and fill the 1 or 2 needed  cells with  

Also, you might wanna look around for some table building classes if your
data is always gonna be really abstract.


Greg Donald - http://destiney.com/
http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/



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




Re: [PHP-DB] Problem connecting to db on Linux

2002-02-18 Thread Greg Donald

> I've been working with PHP/MySQL on Win NT and Win 2000 for a few weeks.
> I've now set up a Linux machine (Mandrake 8.1 on Dell laptop) and have
moved
> my files across.
>
> I use an include file which logs on to the MySQL server and then connects
to
> the database. It performs the login ok but not the select db part.
>
> I tried creating a db using a php script and then selecting it and got the
> same problem.
>
> I'm new on Linux so it might be something in the configuration which needs
> working on.
>
> Any suggestions?

Well, if you had posted some code, someone might have seen the error...  :(

Anyway, here is how i do it:

if($db = mysql_pconnect($dbhost, $dbuser, $dbpasswd)){
mysql_select_db($dbname, $db);
} else {
echo mysql_error();
exit;
}

----
Greg Donald - http://destiney.com/
http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/



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




Re: [PHP-DB] Beginner query about mysql...

2002-02-17 Thread Greg Donald

> I have a table with a ID field 'auto_increment',
>   when i insert a record in the table,
>   how can i know the value of the ID inserted by the mySQL?

mysql_insert_id()

http://www.php.net/manual/en/function.mysql-insert-id.php

-------- 
Greg Donald - http://destiney.com/
http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/



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




Re: [PHP-DB] Session End

2002-02-17 Thread Greg Donald

> I want to know if there is a way in PHP to sence that the visitor left the
> site, I think the answer is in PHP-Sessions, but I don't know how, Any
help
> please??

Use cookies.

http://www.php.net/manual/en/features.cookies.php

--------
Greg Donald - http://destiney.com/
http://phprated.com/ | http://phplinks.org/ | http://phptopsites.com/



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




RE: [PHP-DB] connection to smtp

2001-03-30 Thread Greg Donald

No, the mail() function will not work without a valid MTA.  I believe the
default is sendmail.  But yeah, you can change that in the php.ini file.

> -Original Message-
> From: fam.paauwe [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 30, 2001 1:20 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] connection to smtp
>
>
> My php mail() function failes to make a connection to my local
> smtp server. Which server is best suitable and what do I have to
> change in my php.ini file so that the mail() function will
> operate correctly?
>
> Does the mail() function work without an smtp server?
> Do I have to have an internet connection to use the mail( ) function?
>
> thanx,
> ufo :-)
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]