Re: [PHP-DB] Help please, back to an error

2004-09-15 Thread Stuart Felenstein
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
 
  ?php
  if ((!isset($_GET[search_fd1])) 
  (!isset($_POST[search_fd1]))) {
  $itemvalue = ;
  } else {
  $itemvalue = qsrequest(search_fd1);
  }
 
  $cellvalue = select
  name=\search_optfd1\option value=\=\ .
  qscheckselected(=,$arryopt[1],selected) .
 less
  or equal/option/select
  select name=\search_fd1\option value=\\ .
  qscheckselected(,$arryitemvalue[1],selected) .
  Please Select/option . qsmysqlgen_listbox(
  Select Distinct `DaysID`,`Days` From staDays
  ,search_fd1,DaysID,Days,$arryitemvalue[1])
 .
  /select . input type=\hidden\
  name=\multisearch_fd1\ value=\\;
  if ($cellvalue == ) {
  $cellvalue = nbsp;;
  }
  print td class= . $css_class . 
 align=Default
 
   . $cellvalue . /td;
 
  ?
 
  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

2004-09-14 Thread Micah Stevens

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

 ?php
 if ((!isset($_GET[search_fd1])) 
 (!isset($_POST[search_fd1]))) {
 $itemvalue = ;
 } else {
 $itemvalue = qsrequest(search_fd1);
 }

 $cellvalue = select
 name=\search_optfd1\option value=\=\ .
 qscheckselected(=,$arryopt[1],selected) . less
 or equal/option/select
 select name=\search_fd1\option value=\\ .
 qscheckselected(,$arryitemvalue[1],selected) .
 Please Select/option . qsmysqlgen_listbox(
 Select Distinct `DaysID`,`Days` From staDays
 ,search_fd1,DaysID,Days,$arryitemvalue[1]) .
 /select . input type=\hidden\
 name=\multisearch_fd1\ value=\\;
 if ($cellvalue == ) {
 $cellvalue = nbsp;;
 }
 print td class= . $css_class .  align=Default

  . $cellvalue . /td;

 ?

 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

2004-03-05 Thread mustafa ocak
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;$icount($temp); $i++){

$sw_list = $temp;

}

return $sw_list;

}

}

But when I go to print the return values in $sw_list all I get is my first
value

so can I get a full list to be return. I have been trying to print it by
using the following

for($i=0; $icount(software_list($sw_list));$i++){

print software_list($sw_list);

}

If any one can help with the comparing of the two list and then display a
tick next too any match that would be a great help too.

Thank you



Ben

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

2003-06-11 Thread Ford, Mike [LSS]
 -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

2003-06-10 Thread Matthew Moldvan
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-
?php
$user =netuser;
$upasswd =netuser;
$dsn =CSSD;
$conn = odbc_connect($dsn,$user,$upasswd);
echo  conn:  $conn;
if  ($conn  =  0)  {
echo  Error  in  connectionBR;
exit;
  }
else  {
echo  PConnection  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



Re: [PHP-DB] help, please

2003-03-31 Thread Hendri
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 Comern Mario [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:
?php

putenv(ORACLE_SID=my_sid);

putenv(ORACLE_HOME=my_path_home);

$handle = ora_plogon(user, ssword)or die;

$cursor = ora_open($handle);

ora_commitoff($handle);

$query = insert into my_tab values ( )...;

ora_parse($cursor, $query) or die;

ora_exec($cursor);

?

But not work.

thank's and regards








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



Re: [PHP-DB] Help please

2002-12-10 Thread DL Neil
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




Re: [PHP-DB] HELP PLEASE!! Get query error when inserting into MySql

2001-10-29 Thread biorn

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

2001-10-29 Thread Ricky Theil

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 errorBr . 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 My Sql

2001-10-29 Thread Rick Emery

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 errorBr . 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 My Sql

2001-10-29 Thread Ricky Theil

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

2001-10-29 Thread Rick Emery

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 errorBr . 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! Complex AND OR LIKE queries MySQL/PHP

2001-09-18 Thread Rick Emery

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
 
user typed in HTML Java Oracle, separated by spaces
 
$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]




RE: [PHP-DB] Help Please! Complex AND OR LIKE queries MySQL/PHP

2001-09-18 Thread Dave Watkinson

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... session - database

2001-08-23 Thread Andre P.

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

2001-04-10 Thread richarda
 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

2001-04-09 Thread Indri

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
 
 
 
 ?php
 $size=20;$cols=46;
 echo "div align=\"center\"";
 if(!$submit){
 echo "form method=\"post\" action=\"addnews.php\"\n";
 echo "tabletrtdnbsp;/td/td/table\n";
 echo "table width=\"450\" border=\"0\" cellspacing=\"1\"
 cellpadding=\"2\" align=\"center\"\n";
 echo "tr valign=\"top\"\n";
 echo "td bgcolor=\"#6A7292\" class=\"text\"* UserNamebr\n";
 echo "input type=\"text\" name=\"uname\" class=\"input\"
 maxlength=\"20\" size=\"".$size."\" value=\"\"\n";
 echo "br\n";
 echo "/td\n";
 echo "td bgcolor=\"#6A7292\" class=\"text\"* Passwordbr\n";
 echo "input type=\"password\" name=\"password\" class=\"input\"
 size=\"".$size."\" value=\"\"\n";
 echo "/td\n";
 echo "/tr\n";
 echo "tr valign=\"top\"\n";
 echo "td bgcolor=\"#565d77\" class=\"text\"* Headlinebr\n";
 echo "input type=\"text\" name=\"headline\" class=\"input\"
 maxlength=\"40\" size=\"".$size."\" value=\"\"\n";
 echo "br\n";
 echo "/td\n";
 echo "/tr\n";
 echo "tr valign=\"top\"\n";
 echo "td colspan=\"2\" bgcolor=\"#565d77\" class=\"text\"*
 Storybr\n";
 echo "textarea name=\"newstext\" cols=\"".$cols."\"
 wrap=\"VIRTUAL\" rows=\"10\" class=\"input\"/textarea\n";
 echo "/td\n";
 echo "/tr\n";
 echo "tr valign=\"top\"\n";
 echo "td bgcolor=\"#7B819A\" align=\"center\"
 colspan=\"2\"\n";
 echo "input type=\"submit\" name=\"submit\" value=\"Add
 Article\" class=\"submit\"input type=\"reset\" name=\"reset\"
 value=\"Clear\" class=\"submit\"\n\n";
 echo "/td\n";
 echo "/tr\n";
 echo "/table/form\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 "/div";
 
 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]