[PHP-DB] query error

2005-04-16 Thread pete M
I've got a database table with a whole list of windows file paths.
eg
Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Binder.lnk
Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Excel.lnk
Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Office Setup.lnk
Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Outlook.lnk
Advent Tower PC\C\Program Files\Microsoft Office\Microsoft PowerPoint.lnk
Advent Tower PC\C\Program Files\Microsoft Office\Microsoft Word.lnk
Advent Tower PC\C\Program Files\Microsoft Office\MS Access Workgroup 
Administrator.lnk
Advent Tower PC\C\Program Files\Microsoft Office\MSCREATE.DIR
Advent Tower PC\C\Program Files\Microsoft Office\OF97SPEC.INI
Advent Tower PC\C\Program Files\Microsoft Office\Office
Advent Tower PC\C\Program Files\Microsoft Office\Office\1033

Now I want my DB query to search for directories .. here's a sample query
select * from ff_files
where full_path
like 'Advent Tower PC\C\freeserve\help\images\%'
doesnt work as the % is taken as a literal '%'
I've aslso tried
like 'Advent Tower PC\\C\\freeserve\\help\\images\%'
I'm completely lost ..
all I want is to return all rows that start with
'Advent Tower PC\C\freeserve\help\images\'
tia
Pete
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Query Error

2003-11-04 Thread Robert Sossomon
I've been racking my brain and the web for finding a solution and no
luck so far.

Here's the form:
$display_block .= HRInput item: form method=post
action=\additem.php\nbsp;nbsp;nbsp;nbsp;Item ID:input
type=\text\ name=\sel_item_id\BRQuantity: select
name=\sel_item_qty\;
$display_block .= option value=\0\0/optionoption value=\1\
selected1/option;
for ($i=2; $i  301; $i++){
 $display_block .= option value=\$i\$i/option;
}
$display_block .= /selectinput type=\hidden\ name=\SESSID\
value=\$PHPSESSID\/tdtdinput type=\hidden\ name=\url\
value=\$_SERVER[PHP_SELF]\BRPrice:input type=\text\
name=\sel_item_price\ size=\5\input type=\submit\
name=\submit\ value=\Add to Cart\/form;


And here is the additem.php file where it check for the info in the
field and it is erroring out.

  //validate item and get item and price
//  $get_iteminfo = select item_num, description from GCN_items where
'item_num' LIKE '%$_POST[sel_item_id]';
  $get_iteminfo = select * from GCN_items where 'item_num' LIKE
'%$_POST[sel_item_id]%';
  $get_iteminfo_res = mysql_query($get_iteminfo) or die(mysql_error());
  
  if (mysql_num_rows($get_iteminfo_res)  1){
//invalid id, send away and show query codes
//header(Location: ohcrud.php);
   print the query I just ran was: $get_iteminfoBR\n;
   print the query I just ran was: $get_iteminfo_resBR\n;
   echo mysql_num_rows($get_iteminfo_res);
exit;


I did have = instead of LIKE before, but the results are the same.

GCN_items has the code I am looking for in it but the query is showing
no results.

HELP!

Robert

~~~
Bureaucrats cut red tape, lengthwise.


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



Re: [PHP-DB] Query Error

2003-11-04 Thread CPT John W. Holmes
From: Robert Sossomon [EMAIL PROTECTED]

 And here is the additem.php file where it check for the info in the
 field and it is erroring out.

It would be rather useful to know the error...

   $get_iteminfo = select * from GCN_items where 'item_num' LIKE
 '%$_POST[sel_item_id]%';

Take away the single quotes around your column name. You're asking for a
'string' LIKE 'another string' and not comparing anything in your column at
all.

You can use backticks around table and column names, though. Maybe that's
what you're trying to achieve.

$get_iteminfo = select * from GCN_items where `item_num` LIKE
'%$_POST[sel_item_id]%';

---John Holmes...

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



RE: [PHP-DB] Query Error

2003-11-04 Thread Robert Sossomon
The errors as it prints are:

The query I just ran was: select * from GCN_items where `item_num` =
'%fm-a294%'
The query I just ran was: Resource id #2
0



-Original Message-
From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 04, 2003 11:04 AM
To: Robert Sossomon; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Query Error


From: Robert Sossomon [EMAIL PROTECTED]

 And here is the additem.php file where it check for the info in the 
 field and it is erroring out.

It would be rather useful to know the error...

   $get_iteminfo = select * from GCN_items where 'item_num' LIKE 
 '%$_POST[sel_item_id]%';

Take away the single quotes around your column name. You're asking for a
'string' LIKE 'another string' and not comparing anything in your column
at all.

You can use backticks around table and column names, though. Maybe
that's what you're trying to achieve.

$get_iteminfo = select * from GCN_items where `item_num` LIKE
'%$_POST[sel_item_id]%';

---John Holmes...

-- 
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] Query Error

2003-11-04 Thread CPT John W. Holmes
From: Robert Sossomon [EMAIL PROTECTED]


 The errors as it prints are:

 The query I just ran was: select * from GCN_items where `item_num` =
 '%fm-a294%'
 The query I just ran was: Resource id #2
 0

Those aren't errors; it's just what you asked the script to display. Your
query simply isn't returning any rows.

You should be using LIKE instead of the equal sign, since I assume you're
looking for a pattern.

select * from GCN_items where `item_num` LIKE '%fm-a294%'

otherwise you're looking for the literal string %fm-a294%

---John Holmes...

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



RE: [PHP-DB] Query Error

2003-11-04 Thread Robert Sossomon
That fixed the output to actually find the information, however I'll be
danged if it is not adding the items to the database.

In fact I am seeing errors with it adding half the stuff to the database
from stuff that was working.

I rebooted the system.  Removed the database, stopped the server.
Started the server. Reloaded the database.  Refreshed the data.  Now I
am not seeing stuff added to the system and I have no idea why.

According to the scripts everything is working fine.  The information is
being passed to the pages correctly and even the output on the page
showed that the data was correct for insertion, however when I look at
the database where the information should be, it is not there.  I'm
losing my mind!

Any thoughts?

~~~
A horse! A horse! My kingdom for a horse!


-Original Message-
From: CPT John W. Holmes [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 04, 2003 1:31 PM
To: Robert Sossomon; [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Query Error


From: Robert Sossomon [EMAIL PROTECTED]


 The errors as it prints are:

 The query I just ran was: select * from GCN_items where `item_num` = 
 '%fm-a294%' The query I just ran was: Resource id #2 0

Those aren't errors; it's just what you asked the script to display.
Your query simply isn't returning any rows.

You should be using LIKE instead of the equal sign, since I assume
you're looking for a pattern.

select * from GCN_items where `item_num` LIKE '%fm-a294%'

otherwise you're looking for the literal string %fm-a294%

---John Holmes...

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



[PHP-DB] Query error

2002-10-02 Thread Wilmar Perez

Hello guys

Does anybody have a clue on what wrong with the following sentence?

select author_code from author where author_code not in 
(select author_code from authorxcat);

Thanks

***
 Wilmar Pérez
 Network Administrator
   Library System
  Tel: ++57(4)2105145
University of Antioquia
   Medellín - Colombia
  2002
***
 
 

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




Re: [PHP-DB] Query error

2002-10-02 Thread Jeffrey_N_Dyke


if you are using mysql, it doesn't support the sub-select.



   
  
Wilmar Perez 
  
[EMAIL PROTECTED]   To: [EMAIL PROTECTED] 
  
ea.edu.cocc:  
  
  Subject: [PHP-DB] Query error
  
10/02/2002 10:54 AM
  
   
  
   
  




Hello guys

Does anybody have a clue on what wrong with the following sentence?

select author_code from author where author_code not in
   (select author_code from authorxcat);

Thanks

***
 Wilmar Pérez
  Network Administrator
   Library System
   Tel: ++57(4)2105145
 University of Antioquia
   Medellín - Colombia
 2002
***



--
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] Query error

2002-10-02 Thread Beau Lebens

If it's on MySQL, then the problem is that it doesn't support nested queries
:)

If it's on something else, i'm afraid i don't know :/

Back to MySQL, you can get around that by doing your select author_code
from authorxcat component query, then put the results into 'x', 'y', 'z'
format, then do something like
select author_code from author where author_code not in ($previousResults)

HTH

Beau

// -Original Message-
// From: Wilmar Perez [mailto:[EMAIL PROTECTED]]
// Sent: Wednesday, 2 October 2002 10:54 PM
// To: [EMAIL PROTECTED]
// Subject: [PHP-DB] Query error
// 
// 
// Hello guys
// 
// Does anybody have a clue on what wrong with the following sentence?
// 
// select author_code from author where author_code not in 
//  (select author_code from authorxcat);
// 
// Thanks
// 
// ***
//  Wilmar Pérez
//  Network Administrator
//Library System
//   Tel: ++57(4)2105145
// University of Antioquia
//Medellín - Colombia
//   2002
// ***  
//   
//  
//  
// 
// -- 
// 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




[PHP-DB] query error

2002-05-05 Thread erich

when i perform query an mysql db, to insert a new record, the PHP says:

Warning: Supplied argument is not a valid MySQL result resource in
g:\wwwroot\phpusermanager-1.0\add_order.php on line 24

the snippet is as follows
?
// connect to the database
$conn = mysql_connect ($db_host, $db_user, $db_passwd);

// select database
mysql_select_db ($db_used, $conn);

// SQL statement
$query = INSERT into order (Ctr_no, OID, Person_in_charge, Source,
Destination, Status)
   VALUES ('$container_num', '$order', '$referrer', '$source', '$dest',
'$status');
mysql_query ($query, $conn);

mysql_close($conn);
?

why the argument isn't valid? how to solve this problem?



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




Re: [PHP-DB] query error

2002-05-05 Thread Jason Wong

On Sunday 05 May 2002 14:44, erich wrote:
 when i perform query an mysql db, to insert a new record, the PHP says:

 Warning: Supplied argument is not a valid MySQL result resource in
 g:\wwwroot\phpusermanager-1.0\add_order.php on line 24

 the snippet is as follows
 ?
 // connect to the database
 $conn = mysql_connect ($db_host, $db_user, $db_passwd);

 // select database
 mysql_select_db ($db_used, $conn);

 // SQL statement
 $query = INSERT into order (Ctr_no, OID, Person_in_charge, Source,
 Destination, Status)
VALUES ('$container_num', '$order', '$referrer', '$source', '$dest',
 '$status');
 mysql_query ($query, $conn);

 mysql_close($conn);
 ?

 why the argument isn't valid? how to solve this problem?

Find out why by putting in some error checking code. See examples in manual 
and check out mysql_error().

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *


/*
Your computer account is overdrawn.  Please reauthorize.
*/

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




Re: [PHP-DB] query error

2002-05-05 Thread Miles Thompson

Echo your INSERT statement, so that you know what it looks like, if you 
have the values you expect, field names are spelled correctly. that you're 
not inserting char into int, etc.

Use mysql_errno() and mysql_err() (Check those against manual to determine 
what error you are getting. Use mysql_affected_rows() to determine the 
number of rows which were inserted.

Finally, you aren't assigning the return value from mysql_query(), so if 
you are testing a variable on line 24 it has nothing assigned to it.

HTH - Miles Thompson

At 02:44 PM 5/5/2002 +0800, erich wrote:
when i perform query an mysql db, to insert a new record, the PHP says:

Warning: Supplied argument is not a valid MySQL result resource in
g:\wwwroot\phpusermanager-1.0\add_order.php on line 24

the snippet is as follows
?
// connect to the database
$conn = mysql_connect ($db_host, $db_user, $db_passwd);

// select database
mysql_select_db ($db_used, $conn);

// SQL statement
$query = INSERT into order (Ctr_no, OID, Person_in_charge, Source,
Destination, Status)
VALUES ('$container_num', '$order', '$referrer', '$source', '$dest',
'$status');
mysql_query ($query, $conn);

mysql_close($conn);
?

why the argument isn't valid? how to solve this problem?



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




[PHP-DB] query error...

2002-02-05 Thread jas

Ok what is wrong with this sql statement?
$sql = UPDATE $table_name SET
c_name=\$c_name\,s_addy=\$s_addy\,city=\$city\,state=\state\zip=\zi
p\,phone=\$phone\;

The error I recieve is as follows
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
/path/to/wwwdemo_change.php3 on line 22

Parse error: parse error in /path/to/wwwdemo_change.php3 on line 22

I have looked on MySQL.com at the update function and it states I can use
the SET under UPDATE for multiple fields separated by a , and it is not
working... Any insight would be great.
Thanks in advance,
Jas



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




Re: [PHP-DB] query error...

2002-02-05 Thread biorn

Try putting single quotes around your variables in your update statement 
instead of the escaped double quotes, they are easier to read. 

Also, were you wanting to update all entries in that table to the same, 
c_name, s_addy, city, state, zip and phone?  If not, you will need to 
add 'where id=$id' (or something along those lines) to your update 
statement.  Otherwise, the way you have it now, it will update every row in 
your database to the same values for the listed fields.  


jas [EMAIL PROTECTED] said:

 Ok what is wrong with this sql statement?
 $sql = UPDATE $table_name SET
 c_name=$c_name,s_addy=$s_addy,city=$city,state=statezip=zi
 p,phone=$phone;
 
 The error I recieve is as follows
 Warning: Unexpected character in input: '' (ASCII=92) state=1 in
 /path/to/wwwdemo_change.php3 on line 22
 
 Parse error: parse error in /path/to/wwwdemo_change.php3 on line 22
 
 I have looked on MySQL.com at the update function and it states I can use
 the SET under UPDATE for multiple fields separated by a , and it is not
 working... Any insight would be great.
 Thanks in advance,
 Jas
 
 
 
 -- 
 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] query error...

2002-02-05 Thread DL Neil

Ok jas

 Ok what is wrong with this sql statement?
 $sql = UPDATE $table_name SET
 c_name=\$c_name\,s_addy=\$s_addy\,city=\$city\,state=\state\zip=\zi
 p\,phone=\$phone\;

insufficient checking:
comma missing between state and zip
 incorrectly escaped before phone
...

 I have looked on MySQL.com at the update function and it states I can use
 the SET under UPDATE for multiple fields separated by a , and it is not
 working... Any insight would be great.

Insight: use ECHO to output $sql to the screen. If the results are less than 
satisfactory, copy-paste the sql
code into native MySQL or a management package, the errmsgs are usually more 
informative/directive.

Regards,
=dn



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




Re: [PHP-DB] query error...

2002-02-05 Thread Miles Thompson

Did you type this out or cut/paste? There was a comma missing between  
state\zip   . Should work when you add the comma.

Add a WHERE condition for the update, otherwise every row will be set to 
these values.
Common practice is to use single quotes around the char variables, saves a 
lot of escaping, keeps things more readable. In connection with this, 
echoing $sql would probably have revealed the missing comma, and don't feel 
badly, we've all done it.

Hope this sees you right - Miles


At 02:43 AM 1/31/2002 -0700, jas wrote:
Ok what is wrong with this sql statement?
$sql = UPDATE $table_name SET
c_name=\$c_name\,s_addy=\$s_addy\,city=\$city\,state=\state\zip=\zi
p\,phone=\$phone\;

The error I recieve is as follows
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in
/path/to/wwwdemo_change.php3 on line 22

Parse error: parse error in /path/to/wwwdemo_change.php3 on line 22

I have looked on MySQL.com at the update function and it states I can use
the SET under UPDATE for multiple fields separated by a , and it is not
working... Any insight would be great.
Thanks in advance,
Jas



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




[PHP-DB] query error

2001-01-25 Thread Randy Johnson

When I run any kind of query this is the value of result  Resource id #2

Example
$result= mysql_query (" Select * from ACCT_TBL ") or die
("Error".mysql_error());

print result;


any ideas?

randy


-- 
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] query error

2001-01-25 Thread Mark Newnham

Looks fine, now retrieve the rows from the query.

 -Original Message-
 From: Randy Johnson [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, January 25, 2001 12:46 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] query error
 
 
 When I run any kind of query this is the value of result  
 Resource id #2
 
 Example
 $result= mysql_query (" Select * from ACCT_TBL ") or die
 ("Error".mysql_error());
 
 print result;
 
 
 any ideas?
 
 randy
 
 
 -- 
 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]