Re: [PHP-DB] Help please, back to an error
Micah, Your right! I regretted this post after I hit send. The code generator is actually okay. I'm learning more about PHP, and what the code actually means, in the event it needs to be modded / edited. Sorry again for the post and thanks for the reply! Stuart --- Micah Stevens <[EMAIL PROTECTED]> wrote: > > I'm thinking you should either get a better code > generator, or learn more > about php.. :) > > -Micah > > On Monday 13 September 2004 02:49 pm, Stuart > Felenstein wrote: > > Thanks to help here I was able to overcome some > ivalid > > query errors. > > > > Now I'm back, (probably the same mistake) > > > > It's coming off of this line: > > > > $sql .= " And > > PostStart >= DATE_SUB(CurDate(), Interval > > ['search_fd1'] day )"; > > > > The 'search_fd1' is one of the form fields where a > > list of values is chosen from. Perhaps I will try > the > > "search_optfd1" > > > > > if ((!isset($_GET["search_fd1"])) && > > (!isset($_POST["search_fd1"]))) { > > $itemvalue = ""; > > } else { > > $itemvalue = qsrequest("search_fd1"); > > } > > > > $cellvalue = " > name=\"search_optfd1\"> > qscheckselected("<=",$arryopt[1],"selected") . > ">less > > or equal > > > qscheckselected("",$arryitemvalue[1],"selected") . > > ">Please Select" . qsmysqlgen_listbox(" > > Select Distinct `DaysID`,`Days` From staDays > > ","search_fd1","DaysID","Days",$arryitemvalue[1]) > . > > "" . " > name=\"multisearch_fd1\" value=\"\">"; > > if ($cellvalue == "") { > > $cellvalue = " "; > > } > > print " align=Default > > > > >" . $cellvalue . ""; > > > > ?> > > > > I hope my question makes sense. I didn't write > this > > code AND I have little knowledge of PHP. > > > > Thank you, > > Stuart > > -- > 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
Re: [PHP-DB] Help please, back to an error
I'm thinking you should either get a better code generator, or learn more about php.. :) -Micah On Monday 13 September 2004 02:49 pm, Stuart Felenstein wrote: > Thanks to help here I was able to overcome some ivalid > query errors. > > Now I'm back, (probably the same mistake) > > It's coming off of this line: > > $sql .= " And > PostStart >= DATE_SUB(CurDate(), Interval > ['search_fd1'] day )"; > > The 'search_fd1' is one of the form fields where a > list of values is chosen from. Perhaps I will try the > "search_optfd1" > > if ((!isset($_GET["search_fd1"])) && > (!isset($_POST["search_fd1"]))) { > $itemvalue = ""; > } else { > $itemvalue = qsrequest("search_fd1"); > } > > $cellvalue = " name=\"search_optfd1\"> qscheckselected("<=",$arryopt[1],"selected") . ">less > or equal > qscheckselected("",$arryitemvalue[1],"selected") . > ">Please Select" . qsmysqlgen_listbox(" > Select Distinct `DaysID`,`Days` From staDays > ","search_fd1","DaysID","Days",$arryitemvalue[1]) . > "" . " name=\"multisearch_fd1\" value=\"\">"; > if ($cellvalue == "") { > $cellvalue = " "; > } > print " > >" . $cellvalue . ""; > > ?> > > I hope my question makes sense. I didn't write this > code AND I have little knowledge of PHP. > > Thank you, > Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Help please, back to an error
Thanks to help here I was able to overcome some ivalid query errors. Now I'm back, (probably the same mistake) It's coming off of this line: $sql .= " And PostStart >= DATE_SUB(CurDate(), Interval ['search_fd1'] day )"; The 'search_fd1' is one of the form fields where a list of values is chosen from. Perhaps I will try the "search_optfd1" less or equal Please Select" . qsmysqlgen_listbox(" Select Distinct `DaysID`,`Days` From staDays ","search_fd1","DaysID","Days",$arryitemvalue[1]) . "" . ""; if ($cellvalue == "") { $cellvalue = " "; } print "" . $cellvalue . ""; ?> I hope my question makes sense. I didn't write this code AND I have little knowledge of PHP. Thank you, Stuart -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Help please
Hi, You can use LEFT OUTER JOIN Table1 : software list Table2 : installed ones $res=mysql_query("select table1.software_name, table2.software_name from table1 left outer join table2 on table1.software_name=table2.software_name"); Check if there is not a matching record on table 2 while($row=mysql_fetch_array($res)){ echo $row[0]; //print software name //check if there is a matching record in table 2 display tick if (!empty($row[1])) display_tick(); } Hope this helps Mustafa - Original Message - From: "Benjamin Jeeves" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, March 05, 2004 1:07 PM Subject: [PHP-DB] Help please hi all, I my querying two tables in mysql the first table I query returns a list of software that I have. Then I query a second table that show me what is installed on a computer. I would then like to be able to display the first list but with a tick next to software installed on a computer. I have treid with making a function that reuten the full list of software but can not get it to to work function below. function software_list(&$software) # Software is a word or it can be empty. { $db_search = "SELECT software_name FROM software_list WHERE software_name LIKE '".$software."%'"; $db_result = mysql_query($db_search); $db_count = mysql_num_rows($db_result); while($sw_result = mysql_fetch_array($db_result)){ $temp = $sw_result[software_name]; for($i=0;$ihttp://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Help please
hi all, I my querying two tables in mysql the first table I query returns a list of software that I have. Then I query a second table that show me what is installed on a computer. I would then like to be able to display the first list but with a tick next to software installed on a computer. I have treid with making a function that reuten the full list of software but can not get it to to work function below. function software_list(&$software) # Software is a word or it can be empty. { $db_search = "SELECT software_name FROM software_list WHERE software_name LIKE '".$software."%'"; $db_result = mysql_query($db_search); $db_count = mysql_num_rows($db_result); while($sw_result = mysql_fetch_array($db_result)){ $temp = $sw_result[software_name]; for($i=0;$i
RE: [PHP-DB] Help Please!! Oracle/PHP connection
> -Original Message- > From: Matthew Moldvan [mailto:[EMAIL PROTECTED] > Sent: 11 June 2003 01:03 > > Have you tried the built in Oracle functions in PHP? > > http://us3.php.net/oracle That's only for Oracle up to version 7. For Oracle 8 or 9, use the OCI extension http://www.php.net/oci8. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Help Please!! Oracle/PHP connection
Have you tried the built in Oracle functions in PHP? http://us3.php.net/oracle oracle_logon() may be useful here ... Let me know if it works out for you. Regards, Matt. -Original Message- From: Y Al Hinai [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 10, 2003 8:03 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Help Please!! Oracle/PHP connection Hey guys, I would really appriciate it if someone can direct me with this problem. On my laptop I have: Windows XP Professional, Oracle 9i Database, Oracle Client Software, PHP4.3.1, and Apache server. PHP and Apache work fine. Oracle i9 by itslef works fine too. However when i tried to connect from PHP to Oracle using the following code: ---Code Start- "; exit; } else { echo "Connection successful\n"; } odbc_Close($conn); ?> Code End-- I get the following error: xxError Start Warning: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\Documents and Settings\Administrator\My Documents\php\project\php14.tmp on line 5 conn: Error in connection xxError End I have already set up the ODBC by going to Administrative Tools -> Data Sources (ODBC) -> User DSN -> and added an "Oracle in OraHome92" driver for my database. Please help me out guys. This is for my Master's Thesis project. Appriciated, Yousef - Do you Yahoo!? Free online calendar with sync to Outlook(TM). -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Help Please!! Oracle/PHP connection
Hey guys, I would really appriciate it if someone can direct me with this problem. On my laptop I have: Windows XP Professional, Oracle 9i Database, Oracle Client Software, PHP4.3.1, and Apache server. PHP and Apache work fine. Oracle i9 by itslef works fine too. However when i tried to connect from PHP to Oracle using the following code: ---Code Start- "; exit; } else { echo "Connection successful\n"; } odbc_Close($conn); ?> Code End-- I get the following error: xxError Start Warning: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\Documents and Settings\Administrator\My Documents\php\project\php14.tmp on line 5 conn: Error in connection xxError End I have already set up the ODBC by going to Administrative Tools -> Data Sources (ODBC) -> User DSN -> and added an "Oracle in OraHome92" driver for my database. Please help me out guys. This is for my Master's Thesis project. Appriciated, Yousef - Do you Yahoo!? Free online calendar with sync to Outlook(TM).
Re: [PHP-DB] help, please
Make sure that u had installed Oracle Client on your Machine and Recompile your php with --with-oracle=$ORACLE_HOME then check wether your Apache included -lpthread -Original Message- From: Marcial Comerón Mariño <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Date: Mon, 31 Mar 2003 07:57:38 -0600 Subject: [PHP-DB] help, please Hi all I'm new with php. I need connect with my db in oracle7.3.3, and doing it: But not work. thank's and regards -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] help, please
Hi all I'm new with php. I need connect with my db in oracle7.3.3, and doing it: But not work. thank's and regards
Re: [PHP-DB] Help please
>From original msg: >> I need to be able to do is increment an mysql database field each time an DN> =possibly an AUTO_INCREMENT field is what is needed here Is that what he has been trying to do? I think SpiderWebb needed to see how many pieces of the item were sold, didnt'he? So let's say he's got a table like: -- TABLE: items -- id item_name sales_rank - Now everytime the order is placed, he needs to query the DB 2 times: // Find out the former sales rank: $sql = "SELECT sales_rank FROM items WHERE id = $item_id_just_sold"; $result = @MySQL_Query( $sql ); $record = MySQL_Fetch_Array( $result ); $new_sales_rank = $record["sales_rank"] + $pcs_just_ordered; // Update the field: $sql = "UPDATE items SET sales_rank = $new_sales_rank WHERE id = $item_id_just_sold"; $result = @MySQL_Query( $sql ); if ( $result && ( MySQL_Num_Rows() == 1 ) ): echo "Successfully updated..."; // It's better to redirect him somewhere else... // ...to prevent 'after-refresh' issues... endif; -- Is that what you wanted? More great sources: www.phpbuilder.com www.webmonkey.com www.hotscripts.com www.google.com > this one is the best, try it It finds everything. Good luck. Michal Stankoviansky - >> item is sold then look at that field to decide which price variable to DN> write >> to the price field of the database. Could someone point me in the right >> direction where I could solve this or to someone who could DN> =when you say "database" twice, can I assume you are talking about two DN> different tables? DN> =if the user has identified the product, then presumably (s)he has also DN> mentioned an order quantity. Thus the easiest thing to do is to query the DN> whole price row from the tbl and make the price-rate choice using your DN> program logic. However it would likely be more efficient to have MySQL do it DN> but to comment we would need to see the tbl schema. DN> =hope that gets you started, DN> =dn DN> PS: there are many tutorials available covering the PHP/MySQL combination. DN> Check with the product home sites and follow links to likely sources. --- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Help please
SpiderWebb, One posting to one list is enough... > I dont know if this is possible in PHP (Newbie) im working on a project > where each product has 3 diffierent prices depending on the amount sold so > say for example 1- 100 price A 101-299 price B and above 300 Price C. What > I need to be able to do is increment an mysql database field each time an =possibly an AUTO_INCREMENT field is what is needed here > item is sold then look at that field to decide which price variable to write > to the price field of the database. Could someone point me in the right > direction where I could solve this or to someone who could =when you say "database" twice, can I assume you are talking about two different tables? =if the user has identified the product, then presumably (s)he has also mentioned an order quantity. Thus the easiest thing to do is to query the whole price row from the tbl and make the price-rate choice using your program logic. However it would likely be more efficient to have MySQL do it but to comment we would need to see the tbl schema. =hope that gets you started, =dn PS: there are many tutorials available covering the PHP/MySQL combination. Check with the product home sites and follow links to likely sources. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Help please
From: "SpiderWebb" <[EMAIL PROTECTED]> Subject: Help nedded Date: 09 December 2002 16:46 I dont know if this is possible in PHP (Newbie) im working on a project where each product has 3 diffierent prices depending on the amount sold so say for example 1- 100 price A 101-299 price B and above 300 Price C. What I need to be able to do is increment an mysql database field each time an item is sold then look at that field to decide which price variable to write to the price field of the database. Could someone point me in the right direction where I could solve this or to someone who could Thanks in advance. Spiderwebb -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] HELP PLEASE!! Get query error when inserting into My Sql
I don't know about SQL server 7. However, when using MySQL (as indicated by your code), it will work. For instance, if your table is: CREATE TABLE mytable ( myID int unsigned auto_increment, value2 int unsigned, value3 char(50) ) Then this will automatically increment myID: INSERT INTO mystable VALUES(NULL,123,"A text string"); INSERT INTO mystable VALUES(NULL,456,"A text string"); INSERT INTO mystable VALUES(NULL,789,"A text string"); -Original Message- From: Ricky Theil [mailto:[EMAIL PROTECTED]] Sent: Monday, October 29, 2001 3:12 PM To: 'Rick Emery'; [EMAIL PROTECTED] Subject: RE: [PHP-DB] HELP PLEASE!! Get query error when inserting into My Sql I was never able to assign a null value to get a row to automatically insert into SQL server 7. It would always give me an error that said something like "you cannot assign the value NULL to an identity field." -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Monday, October 29, 2001 10:46 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] HELP PLEASE!! Get query error when inserting into My Sql This also works: INSERT INTO vcstats VALUES( NULL,column2,column3,column4,column5) The NULL value will be replaced with theauto-incremented value in the table -Original Message- From: Ricky Theil [mailto:[EMAIL PROTECTED]] Sent: Monday, October 29, 2001 10:26 AM To: '[EMAIL PROTECTED]'; Robby Whiteside; [EMAIL PROTECTED] Subject: RE: [PHP-DB] HELP PLEASE!! Get query error when inserting into My Sql If your first field is an auto insert field, then you have to do it like this: insert into tablename (column2,column3,column4,column5) values (value2,value3,value4,value5) The auto incremented field will be automatically be filled in with the next available value. Ricky -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, October 29, 2001 9:24 AM To: Robby Whiteside; [EMAIL PROTECTED] Subject: Re: [PHP-DB] HELP PLEASE!! Get query error when inserting into MySql If any of the values you are trying to insert are not integers, you need to put single quotes around the variables, ie. $SCRIPT_NAME, $date, $BName, etc in the insert statement. Robby Whiteside <[EMAIL PROTECTED]> said: > Hi There, > > I have a query whenever I try to insert something into a mysql table. > This is > the code I am using: > > $host1 = gethostbyaddr("$REMOTE_ADDR"); > $date = date("Y-m-d h:i:s"); > $link = mysql_connect("$host", "$user", "$passwd"); > mysql_select_db("$database", $link); $sql = "INSERT INTO vcstats > VALUES('', $SCRIPT_NAME, $date, $HTTP_USER_AGENT, > $BName, $BVersion, $BPlatform, $REMOTE_ADDR, $host1)"; $result = > mysql_query($sql) or die("query error" . mysql_error()); > mysql_close(); > > ?> > > Thanks, > Robby > > - > This message was sent using Endymion MailMan. > http://www.endymion.com/products/mailman/ > > > > -- > 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] > -- -- 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] -- 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] -- 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] -- 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]
RE: [PHP-DB] HELP PLEASE!! Get query error when inserting into My Sql
I was never able to assign a null value to get a row to automatically insert into SQL server 7. It would always give me an error that said something like "you cannot assign the value NULL to an identity field." -Original Message- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Monday, October 29, 2001 10:46 AM To: [EMAIL PROTECTED] Subject: RE: [PHP-DB] HELP PLEASE!! Get query error when inserting into My Sql This also works: INSERT INTO vcstats VALUES( NULL,column2,column3,column4,column5) The NULL value will be replaced with theauto-incremented value in the table -Original Message- From: Ricky Theil [mailto:[EMAIL PROTECTED]] Sent: Monday, October 29, 2001 10:26 AM To: '[EMAIL PROTECTED]'; Robby Whiteside; [EMAIL PROTECTED] Subject: RE: [PHP-DB] HELP PLEASE!! Get query error when inserting into My Sql If your first field is an auto insert field, then you have to do it like this: insert into tablename (column2,column3,column4,column5) values (value2,value3,value4,value5) The auto incremented field will be automatically be filled in with the next available value. Ricky -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, October 29, 2001 9:24 AM To: Robby Whiteside; [EMAIL PROTECTED] Subject: Re: [PHP-DB] HELP PLEASE!! Get query error when inserting into MySql If any of the values you are trying to insert are not integers, you need to put single quotes around the variables, ie. $SCRIPT_NAME, $date, $BName, etc in the insert statement. Robby Whiteside <[EMAIL PROTECTED]> said: > Hi There, > > I have a query whenever I try to insert something into a mysql table. > This is > the code I am using: > > $host1 = gethostbyaddr("$REMOTE_ADDR"); > $date = date("Y-m-d h:i:s"); > $link = mysql_connect("$host", "$user", "$passwd"); > mysql_select_db("$database", $link); $sql = "INSERT INTO vcstats > VALUES('', $SCRIPT_NAME, $date, $HTTP_USER_AGENT, > $BName, $BVersion, $BPlatform, $REMOTE_ADDR, $host1)"; $result = > mysql_query($sql) or die("query error" . mysql_error()); > mysql_close(); > > ?> > > Thanks, > Robby > > - > This message was sent using Endymion MailMan. > http://www.endymion.com/products/mailman/ > > > > -- > 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] > -- -- 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] -- 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] -- 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] -- 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]
RE: [PHP-DB] HELP PLEASE!! Get query error when inserting into My Sql
This also works: INSERT INTO vcstats VALUES( NULL,column2,column3,column4,column5) The NULL value will be replaced with theauto-incremented value in the table -Original Message- From: Ricky Theil [mailto:[EMAIL PROTECTED]] Sent: Monday, October 29, 2001 10:26 AM To: '[EMAIL PROTECTED]'; Robby Whiteside; [EMAIL PROTECTED] Subject: RE: [PHP-DB] HELP PLEASE!! Get query error when inserting into My Sql If your first field is an auto insert field, then you have to do it like this: insert into tablename (column2,column3,column4,column5) values (value2,value3,value4,value5) The auto incremented field will be automatically be filled in with the next available value. Ricky -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, October 29, 2001 9:24 AM To: Robby Whiteside; [EMAIL PROTECTED] Subject: Re: [PHP-DB] HELP PLEASE!! Get query error when inserting into MySql If any of the values you are trying to insert are not integers, you need to put single quotes around the variables, ie. $SCRIPT_NAME, $date, $BName, etc in the insert statement. Robby Whiteside <[EMAIL PROTECTED]> said: > Hi There, > > I have a query whenever I try to insert something into a mysql table. > This is > the code I am using: > > $host1 = gethostbyaddr("$REMOTE_ADDR"); > $date = date("Y-m-d h:i:s"); > $link = mysql_connect("$host", "$user", "$passwd"); > mysql_select_db("$database", $link); $sql = "INSERT INTO vcstats > VALUES('', $SCRIPT_NAME, $date, $HTTP_USER_AGENT, > $BName, $BVersion, $BPlatform, $REMOTE_ADDR, $host1)"; $result = > mysql_query($sql) or die("query error" . mysql_error()); > mysql_close(); > > ?> > > Thanks, > Robby > > - > This message was sent using Endymion MailMan. > http://www.endymion.com/products/mailman/ > > > > -- > 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] > -- -- 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] -- 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] -- 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]
RE: [PHP-DB] HELP PLEASE!! Get query error when inserting into MySql
If your first field is an auto insert field, then you have to do it like this: insert into tablename (column2,column3,column4,column5) values (value2,value3,value4,value5) The auto incremented field will be automatically be filled in with the next available value. Ricky -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Monday, October 29, 2001 9:24 AM To: Robby Whiteside; [EMAIL PROTECTED] Subject: Re: [PHP-DB] HELP PLEASE!! Get query error when inserting into MySql If any of the values you are trying to insert are not integers, you need to put single quotes around the variables, ie. $SCRIPT_NAME, $date, $BName, etc in the insert statement. Robby Whiteside <[EMAIL PROTECTED]> said: > Hi There, > > I have a query whenever I try to insert something into a mysql table. > This is > the code I am using: > > $host1 = gethostbyaddr("$REMOTE_ADDR"); > $date = date("Y-m-d h:i:s"); > $link = mysql_connect("$host", "$user", "$passwd"); > mysql_select_db("$database", $link); $sql = "INSERT INTO vcstats > VALUES('', $SCRIPT_NAME, $date, $HTTP_USER_AGENT, > $BName, $BVersion, $BPlatform, $REMOTE_ADDR, $host1)"; $result = > mysql_query($sql) or die("query error" . mysql_error()); > mysql_close(); > > ?> > > Thanks, > Robby > > - > This message was sent using Endymion MailMan. > http://www.endymion.com/products/mailman/ > > > > -- > 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] > -- -- 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] -- 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]
Re: [PHP-DB] HELP PLEASE!! Get query error when inserting into MySql
If any of the values you are trying to insert are not integers, you need to put single quotes around the variables, ie. $SCRIPT_NAME, $date, $BName, etc in the insert statement. Robby Whiteside <[EMAIL PROTECTED]> said: > Hi There, > > I have a query whenever I try to insert something into a mysql table. This is > the code I am using: > > $host1 = gethostbyaddr("$REMOTE_ADDR"); > $date = date("Y-m-d h:i:s"); > $link = mysql_connect("$host", "$user", "$passwd"); > mysql_select_db("$database", $link); > $sql = "INSERT INTO vcstats VALUES('', $SCRIPT_NAME, $date, $HTTP_USER_AGENT, > $BName, $BVersion, $BPlatform, $REMOTE_ADDR, $host1)"; > $result = mysql_query($sql) or die("query error" . mysql_error()); > mysql_close(); > > ?> > > Thanks, > Robby > > - > This message was sent using Endymion MailMan. > http://www.endymion.com/products/mailman/ > > > > -- > 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] > -- -- 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]
Re: [PHP-DB] HELP PLEASE!! Get query error when inserting into MySql
Joshua, Thanks for this. The original question wasn't mine, but I'm sure Robby will be interested to read it... =dn - Original Message - From: "Joshua Long" <[EMAIL PROTECTED]> To: "DL Neil" <[EMAIL PROTECTED]> Sent: 28 October 2001 07:10 Subject: Re: [PHP-DB] HELP PLEASE!! Get query error when inserting into MySql > Hmm, I'm not sure if this will help, but it can't hurt. > > > > $sql = "INSERT INTO vcstats VALUES('', $SCRIPT_NAME, $date, > $HTTP_USER_AGENT,$BName, $BVersion, $BPlatform, $REMOTE_ADDR, $host1)"; > > I suspect that this si your problem: you have commas where a string joiner > thingy should be, ie > > $sql = "INSERT INTO vcstats VALUES( " ; /* < --- prior to this, > you had a comma.*/ > $sql .= "$SCRIPT_NAME, $date, $HTTP_USER_AGENT,$BName, $BVersion, > $BPlatform, $REMOTE_ADDR, $host1 ) " ; > > -- 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]
Re: [PHP-DB] HELP PLEASE!! Get query error when inserting into MySql
> I have a query whenever I try to insert something into a mysql table. This is > the code I am using: > > $host1 = gethostbyaddr("$REMOTE_ADDR"); > $date = date("Y-m-d h:i:s"); > $link = mysql_connect("$host", "$user", "$passwd"); > mysql_select_db("$database", $link); > $sql = "INSERT INTO vcstats VALUES('', $SCRIPT_NAME, $date, $HTTP_USER_AGENT, > $BName, $BVersion, $BPlatform, $REMOTE_ADDR, $host1)"; > $result = mysql_query($sql) or die("query error" . mysql_error()); > mysql_close(); > > ?> Robby, Queries are the term used to describe all interactions with a db - that's why the function is called mysql_query. It would be helpful if you told us the error message you are receiving. As a matter of style, it would also help you if you checked the response from each function call, or at least echo-ed it so that you could see the returned information. In that case, you would see that processing doesn't get as far as the INSERT operation before failing, and would be able to focus on working out a solution from the manual/your guiding text. Assuming you define the PHP variables $host, $user, $passwd, and $database, somewhere earlier in the script, then the most likely problem is that they are enclosed within quotation marks inside the mysql_connect() and mysql_select_db() calls. Quotation marks are only required if string literals are being specified. Come back to us if that doesn't do the trick, =dn -- 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]
[PHP-DB] HELP PLEASE!! Get query error when inserting into MySql
Hi There, I have a query whenever I try to insert something into a mysql table. This is the code I am using: " . mysql_error()); mysql_close(); ?> Thanks, Robby - This message was sent using Endymion MailMan. http://www.endymion.com/products/mailman/ -- 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]
RE: [PHP-DB] Help Please! Complex AND OR LIKE queries MySQL/PHP
Cheers Rick ... I think I nailed it. I've copied my little function below for anyone else interested. Am keen on the "saving milliseconds" bit, though (will add it to the function below before making it live). Any more tips? Dave function parse($what) { $what = strtolower($what); $what = ltrim($what); $what = rtrim($what); $wa = explode(" ",$what); for ($i=0; $i<= sizeof($wa); $i++) { if (strlen($wa[$i]) !==0) { $j = $i + 1; if ($wa[$i] == "or") { $output .= " OR search_column LIKE '%$wa[$j]%' "; $i++; } elseif ($wa[$i] == "and") { $output .= " AND search_column LIKE '%$wa[$j]%' "; $i++; } elseif ($wa[$i] == "not") { $output .= " AND search_column NOT LIKE '%$wa[$j]%' "; $i++; } else { $output .= " AND search_column LIKE '%$wa[$i]%' "; } } } // strip leading AND from every option $output = substr($output, 4, strlen($output)-3); $what = $output; return $what; } -- 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]
RE: [PHP-DB] Help Please! Complex AND OR LIKE queries MySQL/PHP
Just use PHP's string searching functions. I had a similar situation where I was inserting user-provided data into a MySQL database. I searched for MySQL "bad words" that I didn't want a hacker to insert into queries, such as DELETE, ADD, INSERT, MODIFY, etc. to prevent mischief. FYI, you can dispense with the tidy-up by adding "1" in your pre-pend phrase and moving the AND to the front of your query. Such as: $sql_text .= " AND column1 LIKE '%$s_a[$s_a_i]%' OR column2 LIKE '%$s_a[$S_a_i]%' "; Then pre-pend with: $sql_text = "SELECT id, columnx, columny FROM sometable WHERE 1" . $sql_text; This will save a few milli-seconds because PHP will not have to execute the "substr($sql_text, 0, strlen($sql_text)-4)" functionality. -Original Message- From: Dave Watkinson [mailto:[EMAIL PROTECTED]] Sent: Tuesday, September 18, 2001 5:26 AM To: PHP-DB List (E-mail) Subject: [PHP-DB] Help Please! Complex AND OR LIKE queries MySQL/PHP Hi everyone I need to write a small search script for our admin site (and eventually for the "outsiders" too!). There's a text box where the user types in what they're searching for. It's easy enough to parse their string into an array and create the query from it, for example $s_a = explode(" ", $user_input); for ($s_a_i=0; $s_a_i<= sizeof($s_a); $s_a_i++) { $sql_text .= " column1 LIKE '%$s_a[$s_a_i]%' OR column2 LIKE '%$s_a[$S_a_i]%' AND "; } and then tidy it up by adding //remove trailing AND $sql_text = substr($sql_text, 0, strlen($sql_text)-4); //prepend start of sql command $sql_text = "SELECT id, columnx, columny FROM sometable WHERE " . $sql_text; and then running the query. However, what I need to be able to do is detect if people have typed in the words AND OR or NOT and handle them appropriately, also remembering that I'll be searching TWO columns in the table every time. Are there perhaps any functions I can get for this? Or is there a really easy way I can do it that's escaped (scuse the pun!) me? Many thanks in advance Dave -- 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]
[PHP-DB] Help Please! Complex AND OR LIKE queries MySQL/PHP
Hi everyone I need to write a small search script for our admin site (and eventually for the "outsiders" too!). There's a text box where the user types in what they're searching for. It's easy enough to parse their string into an array and create the query from it, for example $s_a = explode(" ", $user_input); for ($s_a_i=0; $s_a_i<= sizeof($s_a); $s_a_i++) { $sql_text .= " column1 LIKE '%$s_a[$s_a_i]%' OR column2 LIKE '%$s_a[$S_a_i]%' AND "; } and then tidy it up by adding //remove trailing AND $sql_text = substr($sql_text, 0, strlen($sql_text)-4); //prepend start of sql command $sql_text = "SELECT id, columnx, columny FROM sometable WHERE " . $sql_text; and then running the query. However, what I need to be able to do is detect if people have typed in the words AND OR or NOT and handle them appropriately, also remembering that I'll be searching TWO columns in the table every time. Are there perhaps any functions I can get for this? Or is there a really easy way I can do it that's escaped (scuse the pun!) me? Many thanks in advance Dave
Re: [PHP-DB] help please... session -> database
cheers andre i tried that too.. and while i can get it to work by extracting with stripslashes i was trying to enter the '.' itself .. when i see the entry in myphpadmin it is still a '@' thanks tho.. brendan Andre P. wrote: > Try > > $link = addslashed($HTTP_SESSION_VARS["HREF"]) > and then use $link in the sql insert > > and.. > stripslashes(query result) > when you retrieve the value and need to display it on the page. > > hth > andre > > brendan wrote: > >> hello, >> i have hit a major stumbling block and am now getting really >> frustrated.. if someone could point me in the right direction i would >> really appreciate it.. >> >> - i have a set of forms across a number of pages >> - the user enters data into each of the forms and these are placed in >> a session variable >> - at the completion of form entry the session variables are supposed >> to be passed to a mysql database >> - one of the variables is a URL for some reason the form entry the >> data is encoded so that a full stop '.' is changed into an AT '@' >> - I have tried urlencoding and decoding the session, using str_replace >> for the @ .. adding slashes >> - for some reason this just wont work .. >> ... >> >> help? >> ... >> >> >> i.e Adds form post to session >> if (is_array($HTTP_POST_VARS)) { >> while (list($var, $value) = each($HTTP_POST_VARS)) { >> session_register($var); >> $HTTP_SESSION_VARS[$var]=$value; >> >> } >> } >> >> >> i.e adds session to database (simplified so as to find problem) >> >> $title =stripslashes($HTTP_SESSION_VARS["title"]); >> $href= $HTTP_SESSION_VARS["HREF"]; >> $fee =stripslashes($HTTP_SESSION_VARS["fee"]); >> >> $result= mysql_query("INSERT INTO links (Title, Hyperlink,fee) VALUES >> ('$title','$href','$fee')") or die(mysql_error()); >> print $result; >> >> > > -- 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]
Re: [PHP-DB] help please... session -> database
Try $link = addslashed($HTTP_SESSION_VARS["HREF"]) and then use $link in the sql insert and.. stripslashes(query result) when you retrieve the value and need to display it on the page. hth andre brendan wrote: > hello, > i have hit a major stumbling block and am now getting really > frustrated.. if someone could point me in the right direction i would > really appreciate it.. > > - i have a set of forms across a number of pages > - the user enters data into each of the forms and these are placed in > a session variable > - at the completion of form entry the session variables are supposed > to be passed to a mysql database > - one of the variables is a URL for some reason the form entry the > data is encoded so that a full stop '.' is changed into an AT '@' > - I have tried urlencoding and decoding the session, using str_replace > for the @ .. adding slashes > - for some reason this just wont work .. > ... > > help? > ... > > > i.e Adds form post to session > if (is_array($HTTP_POST_VARS)) { > while (list($var, $value) = each($HTTP_POST_VARS)) { > session_register($var); > $HTTP_SESSION_VARS[$var]=$value; > > } > } > > > i.e adds session to database (simplified so as to find problem) > > $title =stripslashes($HTTP_SESSION_VARS["title"]); > $href= $HTTP_SESSION_VARS["HREF"]; > $fee =stripslashes($HTTP_SESSION_VARS["fee"]); > > $result= mysql_query("INSERT INTO links (Title, Hyperlink,fee) VALUES > ('$title','$href','$fee')") or die(mysql_error()); > print $result; > > -- 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]
[PHP-DB] help please... session -> database
hello, i have hit a major stumbling block and am now getting really frustrated.. if someone could point me in the right direction i would really appreciate it.. - i have a set of forms across a number of pages - the user enters data into each of the forms and these are placed in a session variable - at the completion of form entry the session variables are supposed to be passed to a mysql database - one of the variables is a URL for some reason the form entry the data is encoded so that a full stop '.' is changed into an AT '@' - I have tried urlencoding and decoding the session, using str_replace for the @ .. adding slashes - for some reason this just wont work .. ... help? ... i.e Adds form post to session if (is_array($HTTP_POST_VARS)) { while (list($var, $value) = each($HTTP_POST_VARS)) { session_register($var); $HTTP_SESSION_VARS[$var]=$value; } } i.e adds session to database (simplified so as to find problem) $title =stripslashes($HTTP_SESSION_VARS["title"]); $href= $HTTP_SESSION_VARS["HREF"]; $fee =stripslashes($HTTP_SESSION_VARS["fee"]); $result= mysql_query("INSERT INTO links (Title, Hyperlink,fee) VALUES ('$title','$href','$fee')") or die(mysql_error()); print $result; -- 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]
[PHP-DB] HELP PLEASE: PHP - Sybase
Hello, I have got a problem, When i try to connect to Sybase from PHP script, I have an error that I am calling undefined function sybase_connect. Does it meen that I have to load some extra module to get this function to work? Or what should I do to resolve this problem ? Thank you. -- 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]
RE: [PHP-DB] Help please
BDY.RTF -- 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]
Re: [PHP-DB] Help please
It's best if you can supply the full code. Code may not need to be attached, you can just put in a text file and send the link so that we all can read. Error in line 42 DOES NOT mean the error is in line 42, sometimes the error can be in the couple of lines before line 42. Best wishes, Indri -- Aletia Hosting - Full-Featured, Superfast Web Hosting PHP, MySQL, Perl, multiple domain support and more. Plans start at $9.95/mth for 200MB + 10GB Transfer http://AletiaHosting.com - AIM: AletiaSales > From: <[EMAIL PROTECTED]> > Reply-To: <[EMAIL PROTECTED]> > Date: Mon, 9 Apr 2001 18:15:52 -0500 > To: <[EMAIL PROTECTED]> > Subject: [PHP-DB] Help please > > Hi all, > > I have a website that I am trying to develop a "add news" page for. > Basically people who have the authority to add news for the site can type in > their username, password, the title of the article, and the article itself > and submit it to the site (which then verifies the username and password and > if successfull adds it to the DB so the news will appear the next time > somone browses to the website. > > This file is an included file into the main page...the $db variable is > valid, and works with all the other pages so far... I am really stumped and > getting frustrated. > > I apologise in advance if I am including too much code in my examplethe > place with the error is a couple lines from the bottom of the code sample. > > > My problem is that I am getting an error when i try to submit the form, code > sample is below. > > The error is: > > Warning: Supplied argument is not a valid MySQL-Link resource in > /usr/www/kyid/public_html/addnews.php on line 42 > > > > $size=20;$cols=46; > echo ""; > if(!$submit){ > echo "\n"; > echo " \n"; > echo " cellpadding=\"2\" align=\"center\">\n"; > echo "\n"; > echo "* UserName\n"; > echo " maxlength=\"20\" size=\"".$size."\" value=\"\">\n"; > echo "\n"; > echo "\n"; > echo "* Password\n"; > echo " size=\"".$size."\" value=\"\">\n"; > echo "\n"; > echo "\n"; > echo "\n"; > echo "* Headline\n"; > echo " maxlength=\"40\" size=\"".$size."\" value=\"\">\n"; > echo "\n"; > echo "\n"; > echo "\n"; > echo "\n"; > echo "* > Story\n"; > echo " wrap=\"VIRTUAL\" rows=\"10\" class=\"input\">\n"; > echo "\n"; > echo "\n"; > echo "\n"; > echo " colspan=\"2\">\n"; > echo " Article\" class=\"submit\"> value=\"Clear\" class=\"submit\">\n\n"; > echo "\n"; > echo "\n"; > echo "\n"; > }else{ > /* More stuff would go in here, but this isn't working. */ > / THE LINE BELOW THIS IS THE ERROR LINE / > $validate = mysql_query("SELECT username, user_password FROM users > WHERE username=".$uname,$db); > } > echo ""; > > Thanks in advance for any help, or please let me know if this should be on > php-general instead... > > Again, thanks > Keith Young. > > > -- > 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] > -- 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]
[PHP-DB] Help please
Hi all, I have a website that I am trying to develop a "add news" page for. Basically people who have the authority to add news for the site can type in their username, password, the title of the article, and the article itself and submit it to the site (which then verifies the username and password and if successfull adds it to the DB so the news will appear the next time somone browses to the website. This file is an included file into the main page...the $db variable is valid, and works with all the other pages so far... I am really stumped and getting frustrated. I apologise in advance if I am including too much code in my examplethe place with the error is a couple lines from the bottom of the code sample. My problem is that I am getting an error when i try to submit the form, code sample is below. The error is: Warning: Supplied argument is not a valid MySQL-Link resource in /usr/www/kyid/public_html/addnews.php on line 42 "; if(!$submit){ echo "\n"; echo " \n"; echo "\n"; echo "\n"; echo "* UserName\n"; echo "\n"; echo "\n"; echo "\n"; echo "* Password\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "* Headline\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "* Story\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n\n"; echo "\n"; echo "\n"; echo "\n"; }else{ /* More stuff would go in here, but this isn't working. */ / THE LINE BELOW THIS IS THE ERROR LINE / $validate = mysql_query("SELECT username, user_password FROM users WHERE username=".$uname,$db); } echo ""; Thanks in advance for any help, or please let me know if this should be on php-general instead... Again, thanks Keith Young. -- 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]