Re: [PHP] How to execute multiples querys
Mauricio Pellegrini a écrit : Hi all I'm trying to execute two querys and they execute perfectly in fact, but after the execution of the first query there suposed to be some variable setted to a certain value. The problem is this variable is not available at the time the second query runs. I`ll try to explain a little bit further //This is my first query $quer1= SET @var1=3 ;//Here I`m suposed to set the value for var1 to 3 mysql_query($quer1); // This is query #2 $query2=SELECT * from table1 where [EMAIL PROTECTED] //Here @var1 doesn`t exist why don't you build the second query directly with the value ? $query2 = SELECT * from table where col1=.$value; why do you need a query to set @VAR1=3 ? (do you plan to use @VAR in another query ?). N F That wasn't really my first attempt. Originally I've tryied the whole thing in just one single query but mysql gave me an error message complinning about the semicolon Please look at this $quer1 = SET @var1=3 ; SELECt * from table1 Where [EMAIL PROTECTED] ; This gave a syntax error from MySQL inmmediately before the ; (semicolon), Please any help greatefully appreciated Thanks Mauricio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to execute multiples querys
On Wed, 2006-04-26 at 10:32, nicolas figaro wrote: Mauricio Pellegrini a écrit : Hi all I'm trying to execute two querys and they execute perfectly in fact, but after the execution of the first query there suposed to be some variable setted to a certain value. The problem is this variable is not available at the time the second query runs. I`ll try to explain a little bit further //This is my first query $quer1= SET @var1=3 ;//Here I`m suposed to set the value for var1 to 3 mysql_query($quer1); // This is query #2 $query2=SELECT * from table1 where [EMAIL PROTECTED] //Here @var1 doesn`t exist why don't you build the second query directly with the value ? $query2 = SELECT * from table where col1=.$value; why do you need a query to set @VAR1=3 ? (do you plan to use @VAR in another query ?). N F That wasn't really my first attempt. Originally I've tryied the whole thing in just one single query but mysql gave me an error message complinning about the semicolon Please look at this $quer1 = SET @var1=3 ; SELECt * from table1 Where [EMAIL PROTECTED] ; This gave a syntax error from MySQL inmmediately before the ; (semicolon), Please any help greatefully appreciated Thanks Mauricio Yes, I need to do it exactly this way. I mean , SET the value for the variable @var1 first. Then execute an undefined number of querys that reference this variable and its value. Thanks Mauricio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to execute multiples querys
On 4/26/06, Mauricio Pellegrini [EMAIL PROTECTED] wrote: On Wed, 2006-04-26 at 10:32, nicolas figaro wrote: Mauricio Pellegrini a écrit : Hi all I'm trying to execute two querys and they execute perfectly in fact, but after the execution of the first query there suposed to be some variable setted to a certain value. The problem is this variable is not available at the time the second query runs. I`ll try to explain a little bit further //This is my first query $quer1= SET @var1=3 ;//Here I`m suposed to set the value for var1 to 3 mysql_query($quer1); // This is query #2 $query2=SELECT * from table1 where [EMAIL PROTECTED] //Here @var1 doesn`t exist If you try this through a mysql console or through something like phpmyadmin does it work? -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to execute multiples querys
Mauricio Pellegrini a écrit : $quer1 = SET @var1=3 ; SELECt * from table1 Where [EMAIL PROTECTED] ; This gave a syntax error from MySQL inmmediately before the ; (semicolon), did you try to run the query above ( SET @var1=3 ; SELECt * from table1 Where [EMAIL PROTECTED] ) directly from a mysql client ? perhaps the @ is interpreted and you have to put a \ before it. try a print $quer1 once $quer1 is set. Please any help greatefully appreciated Thanks Mauricio Yes, I need to do it exactly this way. I mean , SET the value for the variable @var1 first. Then execute an undefined number of querys that reference this variable and its value. Thanks Mauricio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to execute multiples querys
On Wed, 2006-04-26 at 11:04, chris smith wrote: On 4/26/06, Mauricio Pellegrini [EMAIL PROTECTED] wrote: On Wed, 2006-04-26 at 10:32, nicolas figaro wrote: Mauricio Pellegrini a écrit : Hi all I'm trying to execute two querys and they execute perfectly in fact, but after the execution of the first query there suposed to be some variable setted to a certain value. The problem is this variable is not available at the time the second query runs. I`ll try to explain a little bit further //This is my first query $quer1= SET @var1=3 ;//Here I`m suposed to set the value for var1 to 3 mysql_query($quer1); // This is query #2 $query2=SELECT * from table1 where [EMAIL PROTECTED] //Here @var1 doesn`t exist If you try this through a mysql console or through something like phpmyadmin does it work? Yes, It works perfectly!. From Mysql console or MysqlCC or EMS MySQLmanager -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to execute multiples querys
On Wed, 2006-04-26 at 11:09, nicolas figaro wrote: Mauricio Pellegrini a écrit : $quer1 = SET @var1=3 ; SELECt * from table1 Where [EMAIL PROTECTED] ; This gave a syntax error from MySQL inmmediately before the ; (semicolon), did you try to run the query above ( SET @var1=3 ; SELECt * from table1 Where [EMAIL PROTECTED] ) directly from a mysql client ? Yes, I did and it Works perfectly. perhaps the @ is interpreted and you have to put a \ before it. try a print $quer1 once $quer1 is set. I've tried this too. The output is sintactically correct. I even copied the output of the query and pasted it to Mysqlcc an executed it perfectly. A few minutes ago I found that mysql_query() cannot execute more than one query at a time so the form mysql_query(SET @var1=3 ; SELECT * from ) is invalid But the other way should work Thanks Mauricio Please any help greatefully appreciated Thanks Mauricio Yes, I need to do it exactly this way. I mean , SET the value for the variable @var1 first. Then execute an undefined number of querys that reference this variable and its value. Thanks Mauricio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to execute multiples querys
On Wed, 2006-04-26 at 11:04, chris smith wrote: On 4/26/06, Mauricio Pellegrini [EMAIL PROTECTED] wrote: On Wed, 2006-04-26 at 10:32, nicolas figaro wrote: Mauricio Pellegrini a écrit : Hi all I'm trying to execute two querys and they execute perfectly in fact, but after the execution of the first query there suposed to be some variable setted to a certain value. The problem is this variable is not available at the time the second query runs. I`ll try to explain a little bit further //This is my first query $quer1= SET @var1=3 ;//Here I`m suposed to set the value for var1 to 3 mysql_query($quer1); // This is query #2 $query2=SELECT * from table1 where [EMAIL PROTECTED] //Here @var1 doesn`t exist If you try this through a mysql console or through something like phpmyadmin does it work? Yes, it works. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to execute multiples querys
You should be able to do this in two calls to the mysql_query() function. mysql_query(SET @var1=3); mysql_query(SELECT * from table1 Where [EMAIL PROTECTED]); 2006/4/26, Mauricio Pellegrini [EMAIL PROTECTED]: Hi all I'm trying to execute two querys and they execute perfectly in fact, but after the execution of the first query there suposed to be some variable setted to a certain value. The problem is this variable is not available at the time the second query runs. I`ll try to explain a little bit further //This is my first query $quer1= SET @var1=3 ;//Here I`m suposed to set the value for var1 to 3 mysql_query($quer1); // This is query #2 $query2=SELECT * from table1 where [EMAIL PROTECTED] //Here @var1 doesn`t exist That wasn't really my first attempt. Originally I've tryied the whole thing in just one single query but mysql gave me an error message complinning about the semicolon Please look at this $quer1 = SET @var1=3 ; SELECt * from table1 Where [EMAIL PROTECTED] ; This gave a syntax error from MySQL inmmediately before the ; (semicolon), Please any help greatefully appreciated Thanks Mauricio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to execute multiples querys
On Wed, 2006-04-26 at 10:36, Mauricio Pellegrini wrote: On Wed, 2006-04-26 at 11:09, nicolas figaro wrote: Mauricio Pellegrini a écrit : $quer1 = SET @var1=3 ; SELECt * from table1 Where [EMAIL PROTECTED] ; This gave a syntax error from MySQL inmmediately before the ; (semicolon), did you try to run the query above ( SET @var1=3 ; SELECt * from table1 Where [EMAIL PROTECTED] ) directly from a mysql client ? Yes, I did and it Works perfectly. perhaps the @ is interpreted and you have to put a \ before it. try a print $quer1 once $quer1 is set. I've tried this too. The output is sintactically correct. I even copied the output of the query and pasted it to Mysqlcc an executed it perfectly. A few minutes ago I found that mysql_query() cannot execute more than one query at a time so the form mysql_query(SET @var1=3 ; SELECT * from ) is invalid But the other way should work Try explicitly retrieving a resource ID from mysql_connect, and explictly use that resource when making the query. Probably not the problem, but sounds like something is being lost from one query to another. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to execute multiples querys,IT is SOLVED!!
On Wed, 2006-04-26 at 13:07, Martin Alterisio wrote: You should be able to do this in two calls to the mysql_query() function. mysql_query(SET @var1=3); mysql_query(SELECT * from table1 Where [EMAIL PROTECTED]); It worked this way! It seems I musta had some other problem somewhere else thank you Thank you all MAuricio 2006/4/26, Mauricio Pellegrini [EMAIL PROTECTED]: Hi all I'm trying to execute two querys and they execute perfectly in fact, but after the execution of the first query there suposed to be some variable setted to a certain value. The problem is this variable is not available at the time the second query runs. I`ll try to explain a little bit further //This is my first query $quer1= SET @var1=3 ;//Here I`m suposed to set the value for var1 to 3 mysql_query($quer1); // This is query #2 $query2=SELECT * from table1 where [EMAIL PROTECTED] //Here @var1 doesn`t exist That wasn't really my first attempt. Originally I've tryied the whole thing in just one single query but mysql gave me an error message complinning about the semicolon Please look at this $quer1 = SET @var1=3 ; SELECt * from table1 Where [EMAIL PROTECTED] ; This gave a syntax error from MySQL inmmediately before the ; (semicolon), Please any help greatefully appreciated Thanks Mauricio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to execute multiples querys
On Wed, 2006-04-26 at 13:48, Robert Cummings wrote: On Wed, 2006-04-26 at 10:36, Mauricio Pellegrini wrote: On Wed, 2006-04-26 at 11:09, nicolas figaro wrote: Mauricio Pellegrini a écrit : $quer1 = SET @var1=3 ; SELECt * from table1 Where [EMAIL PROTECTED] ; This gave a syntax error from MySQL inmmediately before the ; (semicolon), did you try to run the query above ( SET @var1=3 ; SELECt * from table1 Where [EMAIL PROTECTED] ) directly from a mysql client ? Yes, I did and it Works perfectly. perhaps the @ is interpreted and you have to put a \ before it. try a print $quer1 once $quer1 is set. I've tried this too. The output is sintactically correct. I even copied the output of the query and pasted it to Mysqlcc an executed it perfectly. A few minutes ago I found that mysql_query() cannot execute more than one query at a time so the form mysql_query(SET @var1=3 ; SELECT * from ) is invalid But the other way should work Try explicitly retrieving a resource ID from mysql_connect, and explictly use that resource when making the query. Probably not the problem, but sounds like something is being lost from one query to another. Thank you that's true. Theres another module in the middle and that is getting only the last query Thanks to all Mauricio Cheers, Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to execute multiples querys
On Wed, April 26, 2006 11:07 am, Martin Alterisio wrote: You should be able to do this in two calls to the mysql_query() function. mysql_query(SET @var1=3); mysql_query(SELECT * from table1 Where [EMAIL PROTECTED]); -bash-2.05b$ php -a Interactive mode enabled ?php mysql_connect('localhost', '***', ''); mysql_select_db('**'); mysql_query(SET @var1 = 3) or print(mysql_error()); $result = mysql_query(SELECT @var1) or print(mysql_error()); print_r(mysql_fetch_row($result)); ? X-Powered-By: PHP/4.4.1 Content-type: text/html Array ( [0] = 3 ) -bash-2.05b$ Yup. Definitely works. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php