Re: [PHP-DB] Re: [PHP] Strange Query Error...

2010-11-27 Thread Karl DeSaulniers


On Nov 27, 2010, at 1:24 PM, Don Wieland wrote:


On Nov 27, 2010, at 10:44 AM, Daniel P. Brown wrote:


   Note how you keep changing case here.  For example, m.aucciim_id
vs. m.AUCCIIM_ID.  Also note that all of this is cAsE-sEnSiTiVe.


You are right. But it still chokes in PHP:

select m.* from Members m inner join Member_Years my on  
m.AUCCIIM_ID = my.member_id where now() < DATE_ADD(DATE_SUB(concat 
(member_year + 1,'-07-01'), INTERVAL 1 DAY), INTERVAL 30 DAY) AND  
m.Preferred_First_Name LIKE 'Don%' group by m.AUCCIIM_ID order by  
m.preferred_last_name


Don



Don't know if you necessarily need this but I found it while checking  
to see if one letter names are a good idea in MySQL statements.

Might help in your like query.

http://techonthenet.com/sql/like.php

HTH,
Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


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



Re: [PHP-DB] ON DUPLICATE KEY UPDATE

2010-11-27 Thread kesavan trichy rengarajan
Read through this:
http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html, especially
the last 2 paragraphs.

On Sun, Nov 28, 2010 at 12:40 PM, Ron Piggott <
ron.pigg...@actsministries.org> wrote:

> My question is with the syntax below: If the “ON DUPLICATE KEY UPDATE
> `name` = '$name'” occurs will $_SESSION['referral_clients_reference'] be
> populated with the mysql_insert_id() value?  If not, should I just query for
> it?  Ron
>
> mysql_query("INSERT INTO `referral_clients` ( `reference` , `name` ,
> `paypal_email` , `last_update` ) VALUES ( NULL , '$name', '$paypal_email',
> CURRENT_TIMESTAMP ) ON DUPLICATE KEY UPDATE `name` = '$name';");
>
> $_SESSION['referral_clients_reference'] = mysql_insert_id();
>
> The Verse of the Day
> “Encouragement from God’s Word”
> http://www.TheVerseOfTheDay.info


[PHP-DB] ON DUPLICATE KEY UPDATE

2010-11-27 Thread Ron Piggott
My question is with the syntax below: If the “ON DUPLICATE KEY UPDATE `name` = 
'$name'” occurs will $_SESSION['referral_clients_reference'] be populated with 
the mysql_insert_id() value?  If not, should I just query for it?  Ron

mysql_query("INSERT INTO `referral_clients` ( `reference` , `name` , 
`paypal_email` , `last_update` ) VALUES ( NULL , '$name', '$paypal_email', 
CURRENT_TIMESTAMP ) ON DUPLICATE KEY UPDATE `name` = '$name';");

$_SESSION['referral_clients_reference'] = mysql_insert_id();

The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info

[PHP-DB] Re: [PHP] Strange Query Error...

2010-11-27 Thread Don Wieland

On Nov 27, 2010, at 10:44 AM, Daniel P. Brown wrote:


   Note how you keep changing case here.  For example, m.aucciim_id
vs. m.AUCCIIM_ID.  Also note that all of this is cAsE-sEnSiTiVe.


You are right. But it still chokes in PHP:

select m.* from Members m inner join Member_Years my on m.AUCCIIM_ID =  
my.member_id where now() < DATE_ADD(DATE_SUB(concat(member_year +  
1,'-07-01'), INTERVAL 1 DAY), INTERVAL 30 DAY) AND  
m.Preferred_First_Name LIKE 'Don%' group by m.AUCCIIM_ID order by  
m.preferred_last_name


Don 

[PHP-DB] Re: [PHP] Strange Query Error...

2010-11-27 Thread Daniel P. Brown
On Sat, Nov 27, 2010 at 13:18, Don Wieland  wrote:
> On Nov 27, 2010, at 10:07 AM, Bastien wrote:
>
>> Try removing the backticks around the table names. If you do use them,
>> then all values (field names and table names) need it.
>
> I tried that and still chokes...
>
> select m.* from Members m inner join Member_Years my on m.aucciim_id =
> my.member_id where now() < DATE_ADD(DATE_SUB(concat(member_year +
> 1,'-07-01'), INTERVAL 1 DAY), INTERVAL 30 DAY) AND m.Preferred_First_Name
> LIKE 'Don%' group by m.AUCCIIM_ID order by m.preferred_last_name
>
> ERROR: You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use near
> 'AND m.Preferred_First_Name LIKE 'Don%'' at line 1

Note how you keep changing case here.  For example, m.aucciim_id
vs. m.AUCCIIM_ID.  Also note that all of this is cAsE-sEnSiTiVe.

-- 

Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

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



Re: [PHP-DB] Re: [PHP] Strange Query Error...

2010-11-27 Thread Niel Archer
> On Nov 27, 2010, at 10:08 AM, Daniel P. Brown wrote:
> 
> > one primary question: are you using the mysql_*
> > family, mysqli_* family, or another method of interfacing with MySQL?
> 
> mysql_
> 
> $results = mysql_query($query) or die(mysql_error());
> 
> Don
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
Could you show the actual code, not just the query. The way you are
setting up the query could be affecting it. i.e. using single quotes when
assigning to a variable would not work with your query.

--
Niel Archer
niel.archer (at) blueyonder.co.uk



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



[PHP-DB] Re: [PHP] Strange Query Error...

2010-11-27 Thread Don Wieland

On Nov 27, 2010, at 10:08 AM, Daniel P. Brown wrote:


one primary question: are you using the mysql_*
family, mysqli_* family, or another method of interfacing with MySQL?


mysql_

$results = mysql_query($query) or die(mysql_error());

Don

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



[PHP-DB] Re: [PHP] Strange Query Error...

2010-11-27 Thread Daniel P. Brown
On Sat, Nov 27, 2010 at 12:30, Don Wieland  wrote:
> Hi gang,
>
> I am executing a query via PHP that gives me a PHP error:
>
> You have an error in your SQL syntax; check the manual that corresponds to
> your MySQL server version for the right syntax to use near 'AND
> m.`Preferred_First_Name` LIKE 'Don' AND m.`Preferred_Last_Name` LIKE
> 'Wielan' at line 1
>
> but when I copy the ECHO of the select query and run it in Sequel Pro Query,
> it returns no error.
>
> Here is the query:
>
> select m.* from Members m inner join Member_Years my on m.aucciim_id =
> my.member_id where now() < DATE_ADD(DATE_SUB(concat(`member_year` +
> 1,'-07-01'), INTERVAL 1 DAY), INTERVAL 30 DAY) AND m.`Preferred_First_Name`
> LIKE 'Don' AND m.`Preferred_Last_Name` LIKE 'Wieland' group by m.AUCCIIM_ID
> order by m.preferred_last_name
>
> What is causing it to choke via PHP?

This is actually better-suited to the DB list (CC'd) than the
General list, but one primary question: are you using the mysql_*
family, mysqli_* family, or another method of interfacing with MySQL?

-- 

Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting
(866-) 725-4321
http://www.parasane.net/

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



Re: [PHP-DB] Using placeholder without pass by reference in MySqli

2010-11-27 Thread None
?> "Bastien"  wrote in message 
news:962f0fd6-0eaa-495a-831e-da05bc1ab...@gmail.com...



On 2010-11-26, at 7:46 PM, "None"  wrote:

> ?Could be a silly question, but i can't find a method to use placeholder 
> (MySqli) without passing by reference (bind_param) or receive by 
> reference (bind_result)? is that right? I really hate use reference 
> becouse in large program is common create a circular reference, even in 
> multiple query with same data i lost the information after first query 
> so i need to clean an refill at every step.

>
> I prefer functions like MySql or DBI.
>
> Do you think it will be implemented, function like param, param_array, 
> fetch_assoc, fetch_all_assoc, etc. where is the correct place to ask for 
> this method? here?

>
> Thank for your advice
>
>
>
> -- 
> PHP Database Mailing List (http://www.php.net/)

> To unsubscribe, visit: http://www.php.net/unsub.php
>

Look at the prepared statements section of mysqli.

Bastien Koert
Sent from my iPhone=



I double checked the entire documentation, but it's not possible to use 
prepared queries without sending or receiving data by reference it only 
accept bind_result and bind_param and, in fact, this's explicitly named in 
http://us.php.net/manual/en/mysqli-stmt.prepare.php


Could I be wrong? there are undocumented methods that allows this?

Thank you as always.


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