Re: [PHP] Problem running sql stored in the database
On 4/9/2004 5:22:12 PM, John Nichel ([EMAIL PROTECTED]) wrote: > John W. Holmes wrote: > > From: "John Nichel" <[EMAIL PROTECTED]> > > > >>>Don't use single quotes. > >>> > >> > >>$sql = "INSERT INTO table (id, name) VALUES ( '" . $id . "', '" . $name > >>. "') > > > > > > awww, come on... someone besides me had to understand wtf Ryan was > > blabbering about, right > > > > ;) ;) ;) > > > > ---John Holmes... > > I have blabbering turned off today. :o ;) Happy to see I bring so much intelligent conversation to the list :-p Cheers, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem running sql stored in the database
John W. Holmes wrote: From: "John Nichel" <[EMAIL PROTECTED]> Don't use single quotes. $sql = "INSERT INTO table (id, name) VALUES ( '" . $id . "', '" . $name . "') awww, come on... someone besides me had to understand wtf Ryan was blabbering about, right ;) ;) ;) ---John Holmes... I have blabbering turned off today. :o ;) -- *** * _ __ __ __ _ * John Nichel * * | |/ /___ __ \ \/ /__ _ _| |__ ___ __ ___ _ __ * 716.856.9675 * * | ' http://www.KegWorks.com[EMAIL PROTECTED] * 14203 - 1321 * *** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem running sql stored in the database
> You have to eval() the code from the database to get the variables > replaced > (or use a regex). > > $name = 'John'; > $str = file_get_contents('test.txt'); //Reads "Hello $name" > eval('$str = "' . $str . '";'); > echo $str; > ?> Hi John, That didn't work (eval i dont know regex well enough so dont use them), I visited the online manual for eval and see that we are on the right track but I am screwing up somewhere...(as usual) rather than explain it over and over and confuse everyone, heres the code i am using: * * * * * * code * * * * * * if($sql_exists == 0){} // first checked if there was any sql associated with this else{$cust_qry=stripslashes($o_sql); echo $i2co_order_number; // Testing to see if this variable holds a value, it does. eval('$i2co_order_number = "'.$i2co_order_number.'";'); // even tried putting cust_qry without success $cust_result = mysql_query($cust_qry); if(!$cust_result){echo 'Error (S1) running your optional custom SQL statement.'.mysql_error();} * * * * * * code * * * * * * comments? suggestions? Thanks, -Ryan A -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem running sql stored in the database
From: "John Nichel" <[EMAIL PROTECTED]> > > Don't use single quotes. > > > > $sql = "INSERT INTO table (id, name) VALUES ( '" . $id . "', '" . $name > . "') awww, come on... someone besides me had to understand wtf Ryan was blabbering about, right ;) ;) ;) ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem running sql stored in the database
Jason Wong wrote: On Friday 09 April 2004 22:24, Ryan A wrote: If that is the case you could modify your insert query: INSERT INTO table (id, name) VALUES ('$id', '$name') No, thats not the problem, its inserting the text "$id" and "$name" instead of the values the variables hold. Don't use single quotes. $sql = "INSERT INTO table (id, name) VALUES ( '" . $id . "', '" . $name . "') -- *** * _ __ __ __ _ * John Nichel * * | |/ /___ __ \ \/ /__ _ _| |__ ___ __ ___ _ __ * 716.856.9675 * * | ' http://www.KegWorks.com[EMAIL PROTECTED] * 14203 - 1321 * *** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem running sql stored in the database
On Friday 09 April 2004 22:24, Ryan A wrote: > > If that is the case you could modify your insert query: > > INSERT INTO table (id, name) VALUES ('$id', '$name') > > No, thats not the problem, its inserting the text "$id" and "$name" instead > of the > values the variables hold. Don't use single quotes. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Do Miami a favor. When you leave, take someone with you. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem running sql stored in the database
From: "Ryan A" <[EMAIL PROTECTED]> > 2. The query also checks if I have a stored sql statement for this C_ID > 2a. If "YES" it tries to execute the query (if NO, execution stops here, all > is well) > > 3.The stored SQL is usually something like "insert into > tester('$client_id','$client_name')" > > Heres where the problems coming in, it seems to be doing everything as it > should except when > I check the database I see that it has inserted: > "$client_id" "$client_name" into the fields instead of "12" "ryan" > > The above should explain everything but if you want the code I can post it. You have to eval() the code from the database to get the variables replaced (or use a regex). or ---John Holmes.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem running sql stored in the database
Hey Richard, Thanks for replying. > If that is the case you could modify your insert query: > INSERT INTO table (id, name) VALUES ('$id', '$name') No, thats not the problem, its inserting the text "$id" and "$name" instead of the values the variables hold. Ideas? Thanks, -Ryan > > > Hi, > > I am getting 2 values from a form: > > > $client_id and $client_name (for understanding: client_id = '12' > > name='ryan') > > > when the client submits the form: > > 1. I run a query in my php script inserts this data into the db,assigns > a > > C_ID. > > > 2. The query also checks if I have a stored sql statement for this C_ID > > 2a. If "YES" it tries to execute the query (if NO, execution stops here, > all > > is well) > > > 3.The stored SQL is usually something like > "insert into > > tester('$client_id','$client_name')" > > > Heres where the problems coming in, it seems to be doing everything as > it > > should except when > > I check the database I see that it has inserted: > > "$client_id" "$client_name" into the fields instead of "12" "ryan" > > > The above should -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Problem running sql stored in the database
Not quite sure what you mean... So I assume the data was written into the worng fields. If that is the case you could modify your insert query: INSERT INTO table (id, name) VALUES ('$id', '$name') hth Richard Friday, April 9, 2004, 4:11:05 PM, you wrote: > Hi, > I am getting 2 values from a form: > $client_id and $client_name (for understanding: client_id = '12' > name='ryan') > when the client submits the form: > 1. I run a query in my php script inserts this data into the db,assigns a > C_ID. > 2. The query also checks if I have a stored sql statement for this C_ID > 2a. If "YES" it tries to execute the query (if NO, execution stops here, all > is well) > 3.The stored SQL is usually something like "insert into > tester('$client_id','$client_name')" > Heres where the problems coming in, it seems to be doing everything as it > should except when > I check the database I see that it has inserted: > "$client_id" "$client_name" into the fields instead of "12" "ryan" > The above should explain everything but if you want the code I can post it. > Kindly reply. > Thanks, > -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php