[PHP-DB] Single Quotes in Form Inputs

2009-07-27 Thread Ben Miller
Hi,

 

I have a form in which my sales reps can add new clients into the database,
but I'm running into a problem if the client's name includes a single quote,
such as O'Henry, when it comes time to input the form data into the database
table.  I'm guessing I need to use ereg_replace, or something similar, to
change the single quote, but I still can't seem to get the syntax right.
Any help would be appreciated.  For what it's worth, here is a shortened
version of what I have:

 

$ firstName = $_POST[form_firstName];

$ lastname = $_POST[form_lastName];

 

$query = mysql_query(INSERT INTO customers (`cust_first`,`cust_last`)
VALUES ('$firstName','$lastName'));

 

Ben Miller

 



[PHP-DB] Date Translation in MySQL

2008-08-05 Thread Ben Miller
I'm looking for a quick and simple way to query a MySQL database by date, or
more specifically, by day of the week.  My dates are stored in the DB in
-MM-DD HH:MM:SS format.  Question, is there a built-in for PHP or MySQL
that will take this column and return only Saturdays, for example, without
having to use PHP to find each of the last X number of Saturdays and then
for each Saturday, query the database?

In case it matters, I am running on PHP v 4.4.7 and MySQL version 4.1.22.

Thanks in advance.



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



RE: [PHP-DB] Date Translation in MySQL

2008-08-05 Thread Ben Miller
Figured there had to be an easier way.  Thank you so much.

-Original Message-
From: Simcha Younger [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 05, 2008 2:48 PM
To: php-db@lists.php.net
Subject: RE: [PHP-DB] Date Translation in MySQL


Select * FROM ... WHERE DAYOFWEEK(datecol)=7

-Original Message-
From: Ben Miller [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 05, 2008 8:10 PM
To: PHP. DB Mail List
Subject: [PHP-DB] Date Translation in MySQL

I'm looking for a quick and simple way to query a MySQL database by date, or
more specifically, by day of the week.  My dates are stored in the DB in
-MM-DD HH:MM:SS format.  Question, is there a built-in for PHP or MySQL
that will take this column and return only Saturdays, for example, without
having to use PHP to find each of the last X number of Saturdays and then
for each Saturday, query the database?

In case it matters, I am running on PHP v 4.4.7 and MySQL version 4.1.22.

Thanks in advance.



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

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.138 / Virus Database: 270.5.12/1592 - Release Date: 05/08/2008
06:03


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