[PHP-DB] What's wrong with this QUERY??

2004-07-22 Thread Harry G
Hi,

I have a database with members details and PK is id.

$thing = [EMAIL PROTECTED];

$query = SELECT id, email, familyname FROM members WHERE email=$thing;
$result = mysql_query($query);

If i do a query where id=$thing.
and $thing=20;
this works fine and I get the desired result. But what is wrong with the
other one, when I do search for the email address??

The email address does exist exactly as quoted above in the email field in
my members table but still doesn't produce any results.

Any help is much appreciated.

Harmeet

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



Re: [PHP-DB] What's wrong with this QUERY??

2004-07-22 Thread Larry E . Ullman
$thing = [EMAIL PROTECTED];
$query = SELECT id, email, familyname FROM members WHERE 
email=$thing;
You need to quote non-numeric values in SQL. It should be
$query = SELECT id, email, familyname FROM members WHERE 
email=''$thing';

Also, you don't really need to select the email value since you should 
already have it.

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


Re: [PHP-DB] What's wrong with this QUERY??

2004-07-22 Thread zareef ahmed
--- Harry G [EMAIL PROTECTED] wrote:
 Hi,
 
 I have a database with members details and PK is id.
 
 $thing = [EMAIL PROTECTED];
 
 $query = SELECT id, email, familyname FROM members
 WHERE email=$thing;

Make it 

$query = SELECT id, email, familyname FROM members
WHERE email='$thing';

It should work

zareef ahmed





 $result = mysql_query($query);
 
 If i do a query where id=$thing.
 and $thing=20;
 this works fine and I get the desired result. But
 what is wrong with the
 other one, when I do search for the email address??
 
 The email address does exist exactly as quoted above
 in the email field in
 my members table but still doesn't produce any
 results.
 
 Any help is much appreciated.
 
 Harmeet
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


=
Zareef Ahmed :: A PHP Developer in Delhi(India).
Homepage :: http://www.zasaifi.com




__
Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!
http://advision.webevents.yahoo.com/yahoo/votelifeengine/

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



Re: [PHP-DB] What's wrong with this QUERY??

2004-07-22 Thread Jason Wong
On Friday 23 July 2004 10:57, Harry G wrote:

 I have a database with members details and PK is id.

 $thing = [EMAIL PROTECTED];

 $query = SELECT id, email, familyname FROM members WHERE email=$thing;

  $query = SELECT id, email, familyname FROM members WHERE email='$thing';

Please refer to some SQL primer to learn the basics of SQL.

 $result = mysql_query($query);

Look at the examples in the manual to see how you can incorporate error 
checking into your code. In particular look at mysql_error().

 If i do a query where id=$thing.
 and $thing=20;
 this works fine and I get the desired result. But what is wrong with the
 other one, when I do search for the email address??

Because your 'id' column is numeric and 'email' column is text. Text columns 
needs their values enclosed by quotes.

 The email address does exist exactly as quoted above in the email field
 in my members table but still doesn't produce any results.

mysql_error() would let you know that there was an error in your query.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
I don't wish to appear overly inquisitive, but are you still alive?
*/

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



[PHP-DB] What's wrong with this IF statement?

2004-04-22 Thread Robert Sossomon
My IF statement should be picking up on the numbers, and if the number
matches not be displaying out the information, however I look at the
outputted page and the information is still there, what have I got wrong
on the code?

CODE SNIPPET
//Show categories first
$get_cats = select id_num, id_name, description, cat_code from
categories order by id_name;
$get_cats_res = mysql_query($get_cats) or die(mysql_error());

if (mysql_num_rows($get_cats_res)  1)
{
 $display_block = PemSorry, no categories to browse./em/P;
}
else
{
 while ($cats = mysql_fetch_array($get_cats_res))
 {
  $cat_id = $cats[id_num];
  if ($cat_id != 53 || $cat_id != 54 || $cat_id != 55 || $cat_id
!= 117 || $cat_id != 118 || $cat_id != 74)
  {
  $cat_title = strtoupper(stripslashes($cats[id_name]));
  $cat_desc = stripslashes($cats[description]);
  $display_block .= stronga
href=$_SERVER[PHP_SELF]?cat_id=$cat_id$cat_title
$cat_desc/a/strongbr\n;
  while ($items = mysql_fetch_array($get_items_res))
   {
$item_id = $items[id];
$item_num = $items[item_num];
$item_desc = stripslashes($items[description]);
if ($item_num != ABC-R37 || $item_num !=  ABC-R42 || $item_num
!= HB-99100 || $item_num != RO-PUMPS || $item_num != ML-HDGALJUG
|| $item_num != PFS-CAC21 || $item_num != PFS-CO2)
{
$item_num = ltrim($item_num);
$item_num = rtrim($item_num);
$display_block .= nbsp;nbsp;nbsp;nbsp;emstronga
href=\catalog/$item_id.html\$item_num/a/strong -
$item_desc/embr\n;
} 
   }
END SNIPPETS

My assumption is that BOTH IF statements are not working correctly since
the logic is that if they are built the same they would react the same.
HELP!

TIA!
Robert

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



[PHP-DB] What's wrong with this query?

2004-02-26 Thread Axel IS Main
I've just tried to do something I've done a thousand times. It does not 
work. I've checked all of the syntax, made sure the field and variable 
names are correct. No matter what I do it just doesn't work. The table 
remains empty. Here's the query:

$logit = mysql_query(INSERT INTO log SET term='$search', 
returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip');

Now that doesn't look too difficult does it? Well, apparently it's 
impossible! I'm really hoping someone out there can see something that I 
missed.

Nick

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


Re: [PHP-DB] What's wrong with this query?

2004-02-26 Thread Ricardo Lopes
What is the error? there i something i always do when i have this problem,
try this:

error_reporting(E_ALL);
$sql = INSERT INTO log SET term='$search', returns='$arrayword',
time=CURTIME(), date=CURDATE(), ip='$ip');
echo $sql;
$logit = mysql_query($sql);


This makes all kind of notice about uninitialized variables and other things
that may cause problems, great for debugging, and the echo $sql prints the
sql that is sent to the client, here you can see if one of the variable yo
are sendding to the query have some kind of problem, like a ' in the middle,
which could cause problems in your script.

If you can't see the problem after this post the output of this code.

- Original Message -
From: Axel IS Main [EMAIL PROTECTED]
To: PHP-DB [EMAIL PROTECTED]
Sent: Thursday, February 26, 2004 9:05 AM
Subject: [PHP-DB] What's wrong with this query?


 I've just tried to do something I've done a thousand times. It does not
 work. I've checked all of the syntax, made sure the field and variable
 names are correct. No matter what I do it just doesn't work. The table
 remains empty. Here's the query:

 $logit = mysql_query(INSERT INTO log SET term='$search',
 returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip');

 Now that doesn't look too difficult does it? Well, apparently it's
 impossible! I'm really hoping someone out there can see something that I
 missed.

 Nick

 --
 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] What's wrong with this query?

2004-02-26 Thread Paul Fitz


You haven't done that a thousand times - the syntax is wrong :).
You are using a combo of INSERT and UPDATE syntax there.

Try 

INSERT INTO log (term, returns, time, date, ip) VALUES ('$search',
'$arrayword',CURTIME(), CURDATE(), '$ip');

Cheers,
Paul



-Original Message-
From: Axel IS Main [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 26, 2004 7:06 PM
To: PHP-DB
Subject: [PHP-DB] What's wrong with this query?


I've just tried to do something I've done a thousand times. It does not 
work. I've checked all of the syntax, made sure the field and variable 
names are correct. No matter what I do it just doesn't work. The table 
remains empty. Here's the query:

$logit = mysql_query(INSERT INTO log SET term='$search', 
returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip');

Now that doesn't look too difficult does it? Well, apparently it's 
impossible! I'm really hoping someone out there can see something that I

missed.

Nick

-- 
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] What's wrong with this query?

2004-02-26 Thread Muhammed Mamedov
Try this:

$logit = mysql_query(INSERT INTO log (term,returns,time,date,ip) VALUES
('$search','$arrayword',CURTIME(), CURDATE(), '$ip'));


Regards,
Muhammed Mamedov
turkmenweb.com

- Original Message -
From: Axel IS Main [EMAIL PROTECTED]
To: PHP-DB [EMAIL PROTECTED]
Sent: Thursday, February 26, 2004 11:05 AM
Subject: [PHP-DB] What's wrong with this query?


 I've just tried to do something I've done a thousand times. It does not
 work. I've checked all of the syntax, made sure the field and variable
 names are correct. No matter what I do it just doesn't work. The table
 remains empty. Here's the query:

 $logit = mysql_query(INSERT INTO log SET term='$search',
 returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip');

 Now that doesn't look too difficult does it? Well, apparently it's
 impossible! I'm really hoping someone out there can see something that I
 missed.

 Nick

 --
 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] What's wrong with this query?

2004-02-26 Thread Axel IS Main
Ok guys, I found the problem. It's actually something I've run into 
before. If you take a look at the query you'll notice that one of the 
fields is named returns. When I created the test table with phpMyAdmin 
it created it and everything seemed fine. Then I decided to try 
something. I tweaked my install script to add creation of the new log 
table and ran it. It failed on that field. When I changed the name of 
the field it worked. I've seen this before when I tried to create a 
field for another database called group. Apparently these are MySQL 
reserved words and you can't use them as names for fields. Go figure. 
Anyway, that solves the problem. When I run it the data is put into the 
table, and the line where I echo the $logit var displays a 1. By the 
way, I changed the name of the returns field to found.

Nick

Micah Stevens wrote:

Right.. a resource.. sorry. 

On Thursday 26 February 2004 12:55 pm, [EMAIL PROTECTED] wrote:
 

An interesting thought. I tried this:

echo Term: $search, Returns: $arrayword, UserIP: $ipbr;
$logit = mysql_query(INSERT INTO log SET term='$search',
returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip');
echo Query Value: $logit;
And got this on the page:

Term: skater, Returns: 312, UserIP: 192.168.1.234
Query Value:
-
mysql_query returns a Resource, which is not a printable 'string', You
could print_r($logit), or var_dump($logit) and you would most likely see
Resouce ID #3 (or some other number). So even if you're query excecutes
properly printing $logit will always show as you've written above.  The
same would hold true of an array, when just using print.
the returned value preceeds the function call in the manual.
from php.net/mysql_query
 resource mysql_query ( string query [, resource link_identifier])
hth
jeff
-
Notice that the variables are set with appropriate values, but the
$logit variable is blank. This, I think is the problem. The question is
why would it do this and not return any type of error? By the way, I
tried this using the other syntax people where suggesting and I got the
same results. I gotta tell you, this one is really kicking my ass. It's
the last piece of an update that I can't release until it's finished.
Nick

Hutchins, Richard wrote:
   

Been kind of following this thread off and on...

If the syntax is acceptable by MySQL, which it appears to be, is it
 

possible

   

that the variables you are using within the query string are not set to
anything? Or is it possible that there is something broken immediately
before the query string is fired?
Most times, when I run into query problems, immediately before I send the
query to the database, I'll echo the statement out to the browser so I can
see the exact string that's being sent to the db.
So can you do this:

$sql = INSERT INTO log SET term='$search', returns='$arrayword',
time=CURTIME(), date=CURDATE(), ip='$ip';
echo $sql;

$logit = mysql_query($sql) or
  die(mysql_error());
And check out what gets spit out to the browser when $sql is echoed? Maybe
that'll point out something that's going wrong. If nothing is apparent,
 

post

   

the results of echo $sql back to the list and maybe one of us will find
something.
HTH.

Rich

 

-Original Message-
From: Axel IS Main [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 26, 2004 2:37 PM
To: PHP DB
Subject: Re: [PHP-DB] What's wrong with this query?
Ok, ok. I get the message about the syntax. Since I've used
this syntax
for a long time and so far there hasn't been a problem I'll assume
that's not the problem. I will, however, review this and
probably make
some changes for the sake of compliance if nothing else. In
any event,
the syntax is NOT why it is failing, smart ass comments by people who
think two years is a long time not withstanding.
As to the useful questions that where asked. There is no
error reported.
Error reporting is set to E_ALL  ~E_NOTICE. I removed the
notice part
so I would get everything and still nothing showed up. I'm
also logging
errors and nothing is showing up in the log either. Not all PHP/MySQL
errors are reported. Sometimes what happens is not considered
an error,
even though it does not do what you would expect it to do. If
the query
syntax was wrong, I would get a syntax error. There is no
error, it just
doesn't write to the table. I can go into phpMyAdmin and with
the same
syntax insert into the table all day long.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   

 



RE: [PHP-DB] What's wrong with this query?

2004-02-26 Thread brett king

I agree this is a valid format. People should check the manual before making
statements that are untrue to the list server.

Axel did you get an error message or just no update?
-Original Message-
From: Nitin Mehta [mailto:[EMAIL PROTECTED]
Sent: 26 February 2004 12:26
To: Erwin Kerk; [EMAIL PROTECTED]; PHP DB
Subject: Re: [PHP-DB] What's wrong with this query?


exactly, i'm using it for more than a year


- Original Message -
From: Erwin Kerk [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; PHP DB [EMAIL PROTECTED]
Sent: Thursday, February 26, 2004 5:36 PM
Subject: Re: [PHP-DB] What's wrong with this query?


 Viorel Dragomir wrote:

  I'm using MySQL for about 2 years and never heard about this kind of
INSERT.
  Is not SQL compliant neither.
 
  YOU CAN NOT MAKE : INSERT INTO table SET var=1 [as I know]

 As a matter of fact it IS possible, according to the MySQL manual on
 http://www.mysql.com/doc/en/INSERT.html

 [snip]
 INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  [INTO] tbl_name [(col_name,...)]
 VALUES ((expression | DEFAULT),...),(...),...
  [ ON DUPLICATE KEY UPDATE col_name=expression, ... ]
 or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  [INTO] tbl_name [(col_name,...)]
 SELECT ...
 HERE- or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  [INTO] tbl_name
 SET col_name=(expression | DEFAULT), ...
  [ ON DUPLICATE KEY UPDATE col_name=expression, ... ]
 [/snip]

 I use this syntax all the time, and always without any trouble.



 @Axel:

 try this:

 $logit = mysql_query(INSERT INTO log SET term='$search',
 returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip') or
 die(mysql_error());

 to see what is going wrong...



 Erwin Kerk
 Web Developer

 --
 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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] What's wrong with this query?

2004-02-26 Thread Axel IS Main
Actually, yes, a thousand times is an obvious exaggeration, but I have 
done a whole lot of times, and the query syntax is the query syntax. 
Different don't make it wrong. This is working in several other places 
throughout this particular set of scripts.

Paul Fitz wrote:

You haven't done that a thousand times - the syntax is wrong :).
You are using a combo of INSERT and UPDATE syntax there.
Try 

INSERT INTO log (term, returns, time, date, ip) VALUES ('$search',
'$arrayword',CURTIME(), CURDATE(), '$ip');
Cheers,
Paul


-Original Message-
From: Axel IS Main [mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 26, 2004 7:06 PM
To: PHP-DB
Subject: [PHP-DB] What's wrong with this query?

I've just tried to do something I've done a thousand times. It does not 
work. I've checked all of the syntax, made sure the field and variable 
names are correct. No matter what I do it just doesn't work. The table 
remains empty. Here's the query:

$logit = mysql_query(INSERT INTO log SET term='$search', 
returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip');

Now that doesn't look too difficult does it? Well, apparently it's 
impossible! I'm really hoping someone out there can see something that I

missed.

Nick

 

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


RE: [PHP-DB] What's wrong with this query?

2004-02-26 Thread Hutchins, Richard
Been kind of following this thread off and on...

If the syntax is acceptable by MySQL, which it appears to be, is it possible
that the variables you are using within the query string are not set to
anything? Or is it possible that there is something broken immediately
before the query string is fired?

Most times, when I run into query problems, immediately before I send the
query to the database, I'll echo the statement out to the browser so I can
see the exact string that's being sent to the db.

So can you do this:

$sql = INSERT INTO log SET term='$search', returns='$arrayword',
time=CURTIME(), date=CURDATE(), ip='$ip';

echo $sql;

$logit = mysql_query($sql) or
die(mysql_error());


And check out what gets spit out to the browser when $sql is echoed? Maybe
that'll point out something that's going wrong. If nothing is apparent, post
the results of echo $sql back to the list and maybe one of us will find
something.

HTH.

Rich

 -Original Message-
 From: Axel IS Main [mailto:[EMAIL PROTECTED]
 Sent: Thursday, February 26, 2004 2:37 PM
 To: PHP DB
 Subject: Re: [PHP-DB] What's wrong with this query?
 
 
 Ok, ok. I get the message about the syntax. Since I've used 
 this syntax 
 for a long time and so far there hasn't been a problem I'll assume 
 that's not the problem. I will, however, review this and 
 probably make 
 some changes for the sake of compliance if nothing else. In 
 any event, 
 the syntax is NOT why it is failing, smart ass comments by people who 
 think two years is a long time not withstanding.
 
 As to the useful questions that where asked. There is no 
 error reported. 
 Error reporting is set to E_ALL  ~E_NOTICE. I removed the 
 notice part 
 so I would get everything and still nothing showed up. I'm 
 also logging 
 errors and nothing is showing up in the log either. Not all PHP/MySQL 
 errors are reported. Sometimes what happens is not considered 
 an error, 
 even though it does not do what you would expect it to do. If 
 the query 
 syntax was wrong, I would get a syntax error. There is no 
 error, it just 
 doesn't write to the table. I can go into phpMyAdmin and with 
 the same 
 syntax insert into the table all day long.
 
 -- 
 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] What's wrong with this query?

2004-02-26 Thread Axel IS Main
An interesting thought. I tried this:

echo Term: $search, Returns: $arrayword, UserIP: $ipbr;
$logit = mysql_query(INSERT INTO log SET term='$search', 
returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip');
echo Query Value: $logit;

And got this on the page:

Term: skater, Returns: 312, UserIP: 192.168.1.234
Query Value:
Notice that the variables are set with appropriate values, but the 
$logit variable is blank. This, I think is the problem. The question is 
why would it do this and not return any type of error? By the way, I 
tried this using the other syntax people where suggesting and I got the 
same results. I gotta tell you, this one is really kicking my ass. It's 
the last piece of an update that I can't release until it's finished.

Nick

Hutchins, Richard wrote:

Been kind of following this thread off and on...

If the syntax is acceptable by MySQL, which it appears to be, is it possible
that the variables you are using within the query string are not set to
anything? Or is it possible that there is something broken immediately
before the query string is fired?
Most times, when I run into query problems, immediately before I send the
query to the database, I'll echo the statement out to the browser so I can
see the exact string that's being sent to the db.
So can you do this:

$sql = INSERT INTO log SET term='$search', returns='$arrayword',
time=CURTIME(), date=CURDATE(), ip='$ip';
echo $sql;

$logit = mysql_query($sql) or
die(mysql_error());
And check out what gets spit out to the browser when $sql is echoed? Maybe
that'll point out something that's going wrong. If nothing is apparent, post
the results of echo $sql back to the list and maybe one of us will find
something.
HTH.

Rich

 

-Original Message-
From: Axel IS Main [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 26, 2004 2:37 PM
To: PHP DB
Subject: Re: [PHP-DB] What's wrong with this query?
Ok, ok. I get the message about the syntax. Since I've used 
this syntax 
for a long time and so far there hasn't been a problem I'll assume 
that's not the problem. I will, however, review this and 
probably make 
some changes for the sake of compliance if nothing else. In 
any event, 
the syntax is NOT why it is failing, smart ass comments by people who 
think two years is a long time not withstanding.

As to the useful questions that where asked. There is no 
error reported. 
Error reporting is set to E_ALL  ~E_NOTICE. I removed the 
notice part 
so I would get everything and still nothing showed up. I'm 
also logging 
errors and nothing is showing up in the log either. Not all PHP/MySQL 
errors are reported. Sometimes what happens is not considered 
an error, 
even though it does not do what you would expect it to do. If 
the query 
syntax was wrong, I would get a syntax error. There is no 
error, it just 
doesn't write to the table. I can go into phpMyAdmin and with 
the same 
syntax insert into the table all day long.

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

 



Re: [PHP-DB] What's wrong with this query?

2004-02-26 Thread Micah Stevens

mysql_query does not return a specific value, rather a pointer to a range of 
values (depending on what the query returns..) so what you're seeing is 
normal. I think depending on your error settings, PHP will actually return 
the value as 'POINTER' or something like that to let you know it's not a real 
variable.. The same thing happens if you try and echo an array.. 

-Micah 

On Thursday 26 February 2004 12:23 pm, Axel IS Main wrote:
 An interesting thought. I tried this:

 echo Term: $search, Returns: $arrayword, UserIP: $ipbr;
 $logit = mysql_query(INSERT INTO log SET term='$search',
 returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip');
 echo Query Value: $logit;

 And got this on the page:

 Term: skater, Returns: 312, UserIP: 192.168.1.234
 Query Value:

 Notice that the variables are set with appropriate values, but the
 $logit variable is blank. This, I think is the problem. The question is
 why would it do this and not return any type of error? By the way, I
 tried this using the other syntax people where suggesting and I got the
 same results. I gotta tell you, this one is really kicking my ass. It's
 the last piece of an update that I can't release until it's finished.

 Nick

 Hutchins, Richard wrote:
 Been kind of following this thread off and on...
 
 If the syntax is acceptable by MySQL, which it appears to be, is it
  possible that the variables you are using within the query string are not
  set to anything? Or is it possible that there is something broken
  immediately before the query string is fired?
 
 Most times, when I run into query problems, immediately before I send the
 query to the database, I'll echo the statement out to the browser so I can
 see the exact string that's being sent to the db.
 
 So can you do this:
 
 $sql = INSERT INTO log SET term='$search', returns='$arrayword',
 time=CURTIME(), date=CURDATE(), ip='$ip';
 
 echo $sql;
 
 $logit = mysql_query($sql) or
  die(mysql_error());
 
 
 And check out what gets spit out to the browser when $sql is echoed? Maybe
 that'll point out something that's going wrong. If nothing is apparent,
  post the results of echo $sql back to the list and maybe one of us will
  find something.
 
 HTH.
 
 Rich
 
 -Original Message-
 From: Axel IS Main [mailto:[EMAIL PROTECTED]
 Sent: Thursday, February 26, 2004 2:37 PM
 To: PHP DB
 Subject: Re: [PHP-DB] What's wrong with this query?
 
 
 Ok, ok. I get the message about the syntax. Since I've used
 this syntax
 for a long time and so far there hasn't been a problem I'll assume
 that's not the problem. I will, however, review this and
 probably make
 some changes for the sake of compliance if nothing else. In
 any event,
 the syntax is NOT why it is failing, smart ass comments by people who
 think two years is a long time not withstanding.
 
 As to the useful questions that where asked. There is no
 error reported.
 Error reporting is set to E_ALL  ~E_NOTICE. I removed the
 notice part
 so I would get everything and still nothing showed up. I'm
 also logging
 errors and nothing is showing up in the log either. Not all PHP/MySQL
 errors are reported. Sometimes what happens is not considered
 an error,
 even though it does not do what you would expect it to do. If
 the query
 syntax was wrong, I would get a syntax error. There is no
 error, it just
 doesn't write to the table. I can go into phpMyAdmin and with
 the same
 syntax insert into the table all day long.
 
 --
 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] What's wrong with this query?

2004-02-26 Thread jeffrey_n_Dyke





An interesting thought. I tried this:

echo Term: $search, Returns: $arrayword, UserIP: $ipbr;
$logit = mysql_query(INSERT INTO log SET term='$search',
returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip');
echo Query Value: $logit;

And got this on the page:

Term: skater, Returns: 312, UserIP: 192.168.1.234
Query Value:


-
mysql_query returns a Resource, which is not a printable 'string', You
could print_r($logit), or var_dump($logit) and you would most likely see
Resouce ID #3 (or some other number). So even if you're query excecutes
properly printing $logit will always show as you've written above.  The
same would hold true of an array, when just using print.

the returned value preceeds the function call in the manual.
from php.net/mysql_query
  resource mysql_query ( string query [, resource link_identifier])


hth
jeff
-


Notice that the variables are set with appropriate values, but the
$logit variable is blank. This, I think is the problem. The question is
why would it do this and not return any type of error? By the way, I
tried this using the other syntax people where suggesting and I got the
same results. I gotta tell you, this one is really kicking my ass. It's
the last piece of an update that I can't release until it's finished.

Nick

Hutchins, Richard wrote:

Been kind of following this thread off and on...

If the syntax is acceptable by MySQL, which it appears to be, is it
possible
that the variables you are using within the query string are not set to
anything? Or is it possible that there is something broken immediately
before the query string is fired?

Most times, when I run into query problems, immediately before I send the
query to the database, I'll echo the statement out to the browser so I can
see the exact string that's being sent to the db.

So can you do this:

$sql = INSERT INTO log SET term='$search', returns='$arrayword',
time=CURTIME(), date=CURDATE(), ip='$ip';

echo $sql;

$logit = mysql_query($sql) or
die(mysql_error());


And check out what gets spit out to the browser when $sql is echoed? Maybe
that'll point out something that's going wrong. If nothing is apparent,
post
the results of echo $sql back to the list and maybe one of us will find
something.

HTH.

Rich



-Original Message-
From: Axel IS Main [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 26, 2004 2:37 PM
To: PHP DB
Subject: Re: [PHP-DB] What's wrong with this query?


Ok, ok. I get the message about the syntax. Since I've used
this syntax
for a long time and so far there hasn't been a problem I'll assume
that's not the problem. I will, however, review this and
probably make
some changes for the sake of compliance if nothing else. In
any event,
the syntax is NOT why it is failing, smart ass comments by people who
think two years is a long time not withstanding.

As to the useful questions that where asked. There is no
error reported.
Error reporting is set to E_ALL  ~E_NOTICE. I removed the
notice part
so I would get everything and still nothing showed up. I'm
also logging
errors and nothing is showing up in the log either. Not all PHP/MySQL
errors are reported. Sometimes what happens is not considered
an error,
even though it does not do what you would expect it to do. If
the query
syntax was wrong, I would get a syntax error. There is no
error, it just
doesn't write to the table. I can go into phpMyAdmin and with
the same
syntax insert into the table all day long.

--
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] What's wrong with this query?

2004-02-26 Thread Micah Stevens

Right.. a resource.. sorry. 

On Thursday 26 February 2004 12:55 pm, [EMAIL PROTECTED] wrote:
 An interesting thought. I tried this:

 echo Term: $search, Returns: $arrayword, UserIP: $ipbr;
 $logit = mysql_query(INSERT INTO log SET term='$search',
 returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip');
 echo Query Value: $logit;

 And got this on the page:

 Term: skater, Returns: 312, UserIP: 192.168.1.234
 Query Value:


 -
 mysql_query returns a Resource, which is not a printable 'string', You
 could print_r($logit), or var_dump($logit) and you would most likely see
 Resouce ID #3 (or some other number). So even if you're query excecutes
 properly printing $logit will always show as you've written above.  The
 same would hold true of an array, when just using print.

 the returned value preceeds the function call in the manual.
 from php.net/mysql_query
   resource mysql_query ( string query [, resource link_identifier])


 hth
 jeff
 -


 Notice that the variables are set with appropriate values, but the
 $logit variable is blank. This, I think is the problem. The question is
 why would it do this and not return any type of error? By the way, I
 tried this using the other syntax people where suggesting and I got the
 same results. I gotta tell you, this one is really kicking my ass. It's
 the last piece of an update that I can't release until it's finished.

 Nick

 Hutchins, Richard wrote:
 Been kind of following this thread off and on...
 
 If the syntax is acceptable by MySQL, which it appears to be, is it

 possible

 that the variables you are using within the query string are not set to
 anything? Or is it possible that there is something broken immediately
 before the query string is fired?
 
 Most times, when I run into query problems, immediately before I send the
 query to the database, I'll echo the statement out to the browser so I can
 see the exact string that's being sent to the db.
 
 So can you do this:
 
 $sql = INSERT INTO log SET term='$search', returns='$arrayword',
 time=CURTIME(), date=CURDATE(), ip='$ip';
 
 echo $sql;
 
 $logit = mysql_query($sql) or
 die(mysql_error());
 
 
 And check out what gets spit out to the browser when $sql is echoed? Maybe
 that'll point out something that's going wrong. If nothing is apparent,

 post

 the results of echo $sql back to the list and maybe one of us will find
 something.
 
 HTH.
 
 Rich
 
 -Original Message-
 From: Axel IS Main [mailto:[EMAIL PROTECTED]
 Sent: Thursday, February 26, 2004 2:37 PM
 To: PHP DB
 Subject: Re: [PHP-DB] What's wrong with this query?
 
 
 Ok, ok. I get the message about the syntax. Since I've used
 this syntax
 for a long time and so far there hasn't been a problem I'll assume
 that's not the problem. I will, however, review this and
 probably make
 some changes for the sake of compliance if nothing else. In
 any event,
 the syntax is NOT why it is failing, smart ass comments by people who
 think two years is a long time not withstanding.
 
 As to the useful questions that where asked. There is no
 error reported.
 Error reporting is set to E_ALL  ~E_NOTICE. I removed the
 notice part
 so I would get everything and still nothing showed up. I'm
 also logging
 errors and nothing is showing up in the log either. Not all PHP/MySQL
 errors are reported. Sometimes what happens is not considered
 an error,
 even though it does not do what you would expect it to do. If
 the query
 syntax was wrong, I would get a syntax error. There is no
 error, it just
 doesn't write to the table. I can go into phpMyAdmin and with
 the same
 syntax insert into the table all day long.
 
 --
 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] What's wrong with this query?

2004-02-26 Thread Micah Stevens

Good point, but all you needed to do is surround the field name with back 
quotes.. i.e.:
$logit = mysql_query(INSERT INTO log SET 
`term`='$search',`returns`='$arrayword', `time`=CURTIME(), `date`=CURDATE(), 
ip='$ip');

I think phpmyadmin does this automatically, which is why that worked. 

-Micah 

On Thursday 26 February 2004 01:12 pm, Axel IS Main wrote:
 Ok guys, I found the problem. It's actually something I've run into
 before. If you take a look at the query you'll notice that one of the
 fields is named returns. When I created the test table with phpMyAdmin
 it created it and everything seemed fine. Then I decided to try
 something. I tweaked my install script to add creation of the new log
 table and ran it. It failed on that field. When I changed the name of
 the field it worked. I've seen this before when I tried to create a
 field for another database called group. Apparently these are MySQL
 reserved words and you can't use them as names for fields. Go figure.
 Anyway, that solves the problem. When I run it the data is put into the
 table, and the line where I echo the $logit var displays a 1. By the
 way, I changed the name of the returns field to found.

 Nick

 Micah Stevens wrote:
 Right.. a resource.. sorry.
 
 On Thursday 26 February 2004 12:55 pm, [EMAIL PROTECTED] wrote:
 An interesting thought. I tried this:
 
 echo Term: $search, Returns: $arrayword, UserIP: $ipbr;
 $logit = mysql_query(INSERT INTO log SET term='$search',
 returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip');
 echo Query Value: $logit;
 
 And got this on the page:
 
 Term: skater, Returns: 312, UserIP: 192.168.1.234
 Query Value:
 
 
 -
 mysql_query returns a Resource, which is not a printable 'string', You
 could print_r($logit), or var_dump($logit) and you would most likely see
 Resouce ID #3 (or some other number). So even if you're query excecutes
 properly printing $logit will always show as you've written above.  The
 same would hold true of an array, when just using print.
 
 the returned value preceeds the function call in the manual.
 from php.net/mysql_query
   resource mysql_query ( string query [, resource link_identifier])
 
 
 hth
 jeff
 -
 
 
 Notice that the variables are set with appropriate values, but the
 $logit variable is blank. This, I think is the problem. The question is
 why would it do this and not return any type of error? By the way, I
 tried this using the other syntax people where suggesting and I got the
 same results. I gotta tell you, this one is really kicking my ass. It's
 the last piece of an update that I can't release until it's finished.
 
 Nick
 
 Hutchins, Richard wrote:
 Been kind of following this thread off and on...
 
 If the syntax is acceptable by MySQL, which it appears to be, is it
 
 possible
 
 that the variables you are using within the query string are not set to
 anything? Or is it possible that there is something broken immediately
 before the query string is fired?
 
 Most times, when I run into query problems, immediately before I send
  the query to the database, I'll echo the statement out to the browser
  so I can see the exact string that's being sent to the db.
 
 So can you do this:
 
 $sql = INSERT INTO log SET term='$search', returns='$arrayword',
 time=CURTIME(), date=CURDATE(), ip='$ip';
 
 echo $sql;
 
 $logit = mysql_query($sql) or
die(mysql_error());
 
 
 And check out what gets spit out to the browser when $sql is echoed?
  Maybe that'll point out something that's going wrong. If nothing is
  apparent,
 
 post
 
 the results of echo $sql back to the list and maybe one of us will find
 something.
 
 HTH.
 
 Rich
 
 -Original Message-
 From: Axel IS Main [mailto:[EMAIL PROTECTED]
 Sent: Thursday, February 26, 2004 2:37 PM
 To: PHP DB
 Subject: Re: [PHP-DB] What's wrong with this query?
 
 
 Ok, ok. I get the message about the syntax. Since I've used
 this syntax
 for a long time and so far there hasn't been a problem I'll assume
 that's not the problem. I will, however, review this and
 probably make
 some changes for the sake of compliance if nothing else. In
 any event,
 the syntax is NOT why it is failing, smart ass comments by people who
 think two years is a long time not withstanding.
 
 As to the useful questions that where asked. There is no
 error reported.
 Error reporting is set to E_ALL  ~E_NOTICE. I removed the
 notice part
 so I would get everything and still nothing showed up. I'm
 also logging
 errors and nothing is showing up in the log either. Not all PHP/MySQL
 errors are reported. Sometimes what happens is not considered
 an error,
 even though it does not do what you would expect it to do. If
 the query
 syntax was wrong, I would get a syntax error. There is no
 error, it just
 doesn't write to the table. I can go into phpMyAdmin and with
 the same
 syntax insert into the table all day long.
 
 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http

Re: [PHP-DB] What's wrong with this query?

2004-02-26 Thread jeffrey_n_Dyke




Ok guys, I found the problem. It's actually something I've run into
before. If you take a look at the query you'll notice that one of the
fields is named returns. When I created the test table with phpMyAdmin
it created it and everything seemed fine. Then I decided to try
something. I tweaked my install script to add creation of the new log
table and ran it. It failed on that field. When I changed the name of
the field it worked. I've seen this before when I tried to create a
field for another database called group. Apparently these are MySQL
reserved words and you can't use them as names for fields. Go figure.
Anyway, that solves the problem. When I run it the data is put into the
table, and the line where I echo the $logit var displays a 1. By the
way, I changed the name of the returns field to found.


just as an FYI, although i would have changed the name as well, if you're
using, or think you are using, a reserved word, you can enclose it in
`backticks` and mysql will treat it as a regular word, which is how
PHPMyAdmin creates and uses all fields. That being said, your solution of
changing the field is better.

Jeff
-


Nick

Micah Stevens wrote:

Right.. a resource.. sorry.

On Thursday 26 February 2004 12:55 pm, [EMAIL PROTECTED] wrote:


An interesting thought. I tried this:

echo Term: $search, Returns: $arrayword, UserIP: $ipbr;
$logit = mysql_query(INSERT INTO log SET term='$search',
returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip');
echo Query Value: $logit;

And got this on the page:

Term: skater, Returns: 312, UserIP: 192.168.1.234
Query Value:


-
mysql_query returns a Resource, which is not a printable 'string', You
could print_r($logit), or var_dump($logit) and you would most likely see
Resouce ID #3 (or some other number). So even if you're query excecutes
properly printing $logit will always show as you've written above.  The
same would hold true of an array, when just using print.

the returned value preceeds the function call in the manual.
from php.net/mysql_query
  resource mysql_query ( string query [, resource link_identifier])


hth
jeff
-


Notice that the variables are set with appropriate values, but the
$logit variable is blank. This, I think is the problem. The question is
why would it do this and not return any type of error? By the way, I
tried this using the other syntax people where suggesting and I got the
same results. I gotta tell you, this one is really kicking my ass. It's
the last piece of an update that I can't release until it's finished.

Nick

Hutchins, Richard wrote:


Been kind of following this thread off and on...

If the syntax is acceptable by MySQL, which it appears to be, is it


possible



that the variables you are using within the query string are not set to
anything? Or is it possible that there is something broken immediately
before the query string is fired?

Most times, when I run into query problems, immediately before I send
the
query to the database, I'll echo the statement out to the browser so I
can
see the exact string that's being sent to the db.

So can you do this:

$sql = INSERT INTO log SET term='$search', returns='$arrayword',
time=CURTIME(), date=CURDATE(), ip='$ip';

echo $sql;

$logit = mysql_query($sql) or
   die(mysql_error());


And check out what gets spit out to the browser when $sql is echoed?
Maybe
that'll point out something that's going wrong. If nothing is apparent,


post



the results of echo $sql back to the list and maybe one of us will find
something.

HTH.

Rich



-Original Message-
From: Axel IS Main [mailto:[EMAIL PROTECTED]
Sent: Thursday, February 26, 2004 2:37 PM
To: PHP DB
Subject: Re: [PHP-DB] What's wrong with this query?


Ok, ok. I get the message about the syntax. Since I've used
this syntax
for a long time and so far there hasn't been a problem I'll assume
that's not the problem. I will, however, review this and
probably make
some changes for the sake of compliance if nothing else. In
any event,
the syntax is NOT why it is failing, smart ass comments by people who
think two years is a long time not withstanding.

As to the useful questions that where asked. There is no
error reported.
Error reporting is set to E_ALL  ~E_NOTICE. I removed the
notice part
so I would get everything and still nothing showed up. I'm
also logging
errors and nothing is showing up in the log either. Not all PHP/MySQL
errors are reported. Sometimes what happens is not considered
an error,
even though it does not do what you would expect it to do. If
the query
syntax was wrong, I would get a syntax error. There is no
error, it just
doesn't write to the table. I can go into phpMyAdmin and with
the same
syntax insert into the table all day long.

--
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] What's wrong with this query?

2004-02-26 Thread Daniel Clark
What about the single quotes?   Might try this.

$sql = INSERT INTO log SET term=\'$search\', returns=\'$arrayword\',
time=CURTIME(), date=CURDATE(), ip=\'$ip\';


 $sql = INSERT INTO log SET term='$search', returns='$arrayword',
 time=CURTIME(), date=CURDATE(), ip='$ip';

 echo $sql;

 $logit = mysql_query($sql) or
   die(mysql_error());

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



Re: [PHP-DB] What's wrong with this query?

2004-02-26 Thread Axel IS Main
Ok, ok. I get the message about the syntax. Since I've used this syntax 
for a long time and so far there hasn't been a problem I'll assume 
that's not the problem. I will, however, review this and probably make 
some changes for the sake of compliance if nothing else. In any event, 
the syntax is NOT why it is failing, smart ass comments by people who 
think two years is a long time not withstanding.

As to the useful questions that where asked. There is no error reported. 
Error reporting is set to E_ALL  ~E_NOTICE. I removed the notice part 
so I would get everything and still nothing showed up. I'm also logging 
errors and nothing is showing up in the log either. Not all PHP/MySQL 
errors are reported. Sometimes what happens is not considered an error, 
even though it does not do what you would expect it to do. If the query 
syntax was wrong, I would get a syntax error. There is no error, it just 
doesn't write to the table. I can go into phpMyAdmin and with the same 
syntax insert into the table all day long.

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


Re: [PHP-DB] What's wrong with this query?

2004-02-26 Thread Nitin Mehta
exactly, i'm using it for more than a year


- Original Message - 
From: Erwin Kerk [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; PHP DB [EMAIL PROTECTED]
Sent: Thursday, February 26, 2004 5:36 PM
Subject: Re: [PHP-DB] What's wrong with this query?


 Viorel Dragomir wrote:

  I'm using MySQL for about 2 years and never heard about this kind of
INSERT.
  Is not SQL compliant neither.
 
  YOU CAN NOT MAKE : INSERT INTO table SET var=1 [as I know]

 As a matter of fact it IS possible, according to the MySQL manual on
 http://www.mysql.com/doc/en/INSERT.html

 [snip]
 INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  [INTO] tbl_name [(col_name,...)]
 VALUES ((expression | DEFAULT),...),(...),...
  [ ON DUPLICATE KEY UPDATE col_name=expression, ... ]
 or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  [INTO] tbl_name [(col_name,...)]
 SELECT ...
 HERE- or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
  [INTO] tbl_name
 SET col_name=(expression | DEFAULT), ...
  [ ON DUPLICATE KEY UPDATE col_name=expression, ... ]
 [/snip]

 I use this syntax all the time, and always without any trouble.



 @Axel:

 try this:

 $logit = mysql_query(INSERT INTO log SET term='$search',
 returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip') or
 die(mysql_error());

 to see what is going wrong...



 Erwin Kerk
 Web Developer

 -- 
 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] What's wrong with this query?

2004-02-26 Thread Erwin Kerk
Viorel Dragomir wrote:

I'm using MySQL for about 2 years and never heard about this kind of INSERT.
Is not SQL compliant neither.
YOU CAN NOT MAKE : INSERT INTO table SET var=1 [as I know]
As a matter of fact it IS possible, according to the MySQL manual on
http://www.mysql.com/doc/en/INSERT.html
[snip]
INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
[INTO] tbl_name [(col_name,...)]
VALUES ((expression | DEFAULT),...),(...),...
[ ON DUPLICATE KEY UPDATE col_name=expression, ... ]
or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
[INTO] tbl_name [(col_name,...)]
SELECT ...
HERE-   or  INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
[INTO] tbl_name
SET col_name=(expression | DEFAULT), ...
[ ON DUPLICATE KEY UPDATE col_name=expression, ... ]
[/snip]
I use this syntax all the time, and always without any trouble.



@Axel:

try this:

$logit = mysql_query(INSERT INTO log SET term='$search', 
returns='$arrayword', time=CURTIME(), date=CURDATE(), ip='$ip') or 
die(mysql_error());

to see what is going wrong...



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


Re: [PHP-DB] What's wrong with my update query select works, but updatedoesn't?

2002-12-26 Thread Michael Knauf/Niles

Here's the code: with some extraneous html removed to make it easier to
read...

? require('connect.php') ?

?
/* check  for  a request to display a new fg number and if so make sure the
data is good
if the fg number is good it is used for all other data queries */
$fgNumber=;
 if  ($switchfg !==){
$switchfg = htmlentities($switchfg , ENT_QUOTES);
  if (strlen($switchfg)  7) {
  echo bad fg number;
  }
  else {
  $fgNumber =$switchfg ;
  echo $fgNumber;
}}
?


This works... I added the echo statement in the last line for debugging
purposes, the page does indeed display the fgNumber, and uses the variable
to perform other queries, which also work... until I try to update the
database


?

if ($tableid==products) {
echo updating products;
  if ($productName !=  and  $productDescription !=) {
  $products_query= UPDATE products SET productName='$productName',
productDescription='$productDescription' where fgNumber='$fgNumber' limit
1;
  $productsResult = mysql_query($products_query);
  echo $products_query;
  }
}
?

Again, that last line is a debugging entry, and it echoes back the query
I'm expecting, except that the variable $fgNumber looses it's value
somewhere and the query looks like this:

UPDATE products SET productName='ZR-4630 MultiZone Receiver',
productDescription='4-Source 6-Zone Receiver with AM/FM Tuner' where
fgNumber='' limit 1

I expect it to say  where fgNumber='FG00813

Here's the form that triggers the update


!-- __ PRODUCTS TABLE
__ --
?
$productsQuery =SELECT id, fgNumber, productName, productDescription FROM
products where fgNumber='$fgNumber' ;
$productsRecordset = mysql_query($productsQuery) or die(mysql_error());
$productsRow=mysql_fetch_array($productsRecordset);
//$fgNumber=$productsRow['fgNumber']
?
form name=products method=post action=? $_SERVER['php_self']
?input name=tableid type=hidden value=products
table width=100% border=0 cellpadding=10 cellspacing=0 bgcolor=
#CC
tr
td colspan=4h2Products Table/h2
hr
/td
/tr
tr
tdID:
input name=productId type=text id=productId
value=? echo $productsRow['id'] ? size=5/td
tdFG#:
input name=fgNumber type=text id
=fgNumber value=? echo $productsRow['fgNumber'] ? size=10/td
tdName:
input name=productName type=text
id=productName value=? echo $productsRow['productName'] ? size
=36/td
tdDescription
input name=productDescription type
=text id=productDescription value=? echo $productsRow
['productDescription'] ? size=48/td
/tr
tr
td colspan=4Update Product Information
input type=submit name=Submit value
=Submit/td
/tr
/table
/form

I keep looking for an error and not finding one, am I missing something
obvious?

Michael




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




RE: [PHP-DB] What's wrong with my update query select works, but update doesn't?

2002-12-26 Thread Ryan Jameson (USA)
Well, it seems to me that if these two happen within the same scope level (same 
function, same class) which I cannot verify based on what you gave us, the $fgNumber 
should not be empty. Therefore I'd bet there's some code in between that reinitializes 
$fgNumber or the update is in a function that does not have access to the $fgNumber. 
You can give a function access to that variable by declaring it global inside of the 
function, or passing it as a variable.

 Ryan

-Original Message-
From: Michael Knauf/Niles [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 26, 2002 1:41 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] What's wrong with my update query select works,
but update doesn't?



Here's the code: with some extraneous html removed to make it easier to
read...

? require('connect.php') ?

?
/* check  for  a request to display a new fg number and if so make sure the
data is good
if the fg number is good it is used for all other data queries */
$fgNumber=;
 if  ($switchfg !==){
$switchfg = htmlentities($switchfg , ENT_QUOTES);
  if (strlen($switchfg)  7) {
  echo bad fg number;
  }
  else {
  $fgNumber =$switchfg ;
  echo $fgNumber;
}}
?


This works... I added the echo statement in the last line for debugging
purposes, the page does indeed display the fgNumber, and uses the variable
to perform other queries, which also work... until I try to update the
database


?

if ($tableid==products) {
echo updating products;
  if ($productName !=  and  $productDescription !=) {
  $products_query= UPDATE products SET productName='$productName',
productDescription='$productDescription' where fgNumber='$fgNumber' limit
1;
  $productsResult = mysql_query($products_query);
  echo $products_query;
  }
}
?

Again, that last line is a debugging entry, and it echoes back the query
I'm expecting, except that the variable $fgNumber looses it's value
somewhere and the query looks like this:

UPDATE products SET productName='ZR-4630 MultiZone Receiver',
productDescription='4-Source 6-Zone Receiver with AM/FM Tuner' where
fgNumber='' limit 1

I expect it to say  where fgNumber='FG00813

Here's the form that triggers the update


!-- __ PRODUCTS TABLE
__ --
?
$productsQuery =SELECT id, fgNumber, productName, productDescription FROM
products where fgNumber='$fgNumber' ;
$productsRecordset = mysql_query($productsQuery) or die(mysql_error());
$productsRow=mysql_fetch_array($productsRecordset);
//$fgNumber=$productsRow['fgNumber']
?
form name=products method=post action=? $_SERVER['php_self']
?input name=tableid type=hidden value=products
table width=100% border=0 cellpadding=10 cellspacing=0 bgcolor=
#CC
tr
td colspan=4h2Products Table/h2
hr
/td
/tr
tr
tdID:
input name=productId type=text id=productId
value=? echo $productsRow['id'] ? size=5/td
tdFG#:
input name=fgNumber type=text id
=fgNumber value=? echo $productsRow['fgNumber'] ? size=10/td
tdName:
input name=productName type=text
id=productName value=? echo $productsRow['productName'] ? size
=36/td
tdDescription
input name=productDescription type
=text id=productDescription value=? echo $productsRow
['productDescription'] ? size=48/td
/tr
tr
td colspan=4Update Product Information
input type=submit name=Submit value
=Submit/td
/tr
/table
/form

I keep looking for an error and not finding one, am I missing something
obvious?

Michael




-- 
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] What's wrong with this code?

2002-09-01 Thread Shoulder to Shoulder Farm

Hi all, I'm running PHP4. What's wrong with this code:

?

$db = mysql_connect(localhost, Taj, wyethia);

mysql_select_db(s2s,$db);

mysql_query(INSERT INTO prod VALUES ( 'Name', 'ShortDesc', 'LongDesc', 
'PriceOZ', 'PriceLB', 'URLOZ', 'URLLB', 'IMG') VALUES ('$_POST[Name]', 
'$_POST[ShortDesc]', '$_POST[LongDesc], '$POST[PriceOZ', 
'$_POST[PriceLB]', '$_POST[URLOZ]', '$_POST[URLLB], '$_POST[IMG]');)

?

This will wrap, but, it should work.

TIA, Taj


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




[PHP-DB] What's wrong with this code?

2002-09-01 Thread Shoulder to Shoulder Farm

Hi all, I'm running PHP4. What's wrong with this code:

?

$db = mysql_connect(localhost, Taj, passwordhere);

mysql_select_db(s2s,$db);

mysql_query(INSERT INTO prod VALUES ( 'Name', 'ShortDesc', 'LongDesc', 
'PriceOZ', 'PriceLB', 'URLOZ', 'URLLB', 'IMG') VALUES ('$_POST[Name]', 
'$_POST[ShortDesc]', '$_POST[LongDesc], '$POST[PriceOZ', 
'$_POST[PriceLB]', '$_POST[URLOZ]', '$_POST[URLLB], '$_POST[IMG]');)

?

This will wrap, but, it should work.

TIA, Taj


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




RE: [PHP-DB] What's wrong with this code?

2002-09-01 Thread Beau Lebens

I'd use var inclusions like this;

VALUES (' . $_POST['Name'] . ', 

that might help you


// -Original Message-
// From: Shoulder to Shoulder Farm [mailto:[EMAIL PROTECTED]]
// Sent: Monday, 2 September 2002 11:42 AM
// To: PHP Database List
// Subject: [PHP-DB] What's wrong with this code?
// 
// 
// Hi all, I'm running PHP4. What's wrong with this code:
// 
// ?
// 
// $db = mysql_connect(localhost, Taj, passwordhere);
// 
// mysql_select_db(s2s,$db);
// 
// mysql_query(INSERT INTO prod VALUES ( 'Name', 'ShortDesc', 
// 'LongDesc', 
// 'PriceOZ', 'PriceLB', 'URLOZ', 'URLLB', 'IMG') VALUES 
// ('$_POST[Name]', 
// '$_POST[ShortDesc]', '$_POST[LongDesc], '$POST[PriceOZ', 
// '$_POST[PriceLB]', '$_POST[URLOZ]', '$_POST[URLLB], '$_POST[IMG]');)
// 
// ?
// 
// This will wrap, but, it should work.
// 
// TIA, Taj
// 
// 
// -- 
// 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] what's wrong with this ereg?

2002-08-20 Thread chip . wiegand

I am trying an email verification function, like this:

 if (empty($useremail)) || !eregi(^[A-Za-z0-9\_-]+@[A-Za-z0-9\_-]
+.[A-Za-z0-9\_-]+.*, $email))
  {
   $errmsg .= The email address appears to be invalid\n;
  }

But it will not work, on one server I get this error:
Parse error: parse error in
/home/virtual/site109/fst/var/www/html/auth_dealers/user_input2.php on line
70
and on another server I get this error:
Parse error: parse error, unexpected T_BOOLEAN_OR in
/usr/local/apache/htdocs/auth_dealers/user_input2.php on line 70

What do I need to do to fix this?

--
Chip Wiegand
Computer Services
Simrad, Inc
www.simradusa.com
[EMAIL PROTECTED]

There is no reason anyone would want a computer in their home.
 --Ken Olson, president, chairman and founder of Digital Equipment
Corporation, 1977
 (They why do I have 9? Somebody help me!)


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




Re: [PHP-DB] what's wrong with this ereg?

2002-08-20 Thread Steve Cayford

Well, one thing is you've got mismatched parentheses. You need another 
another opening paren right after the if.

Also, don't you need to escape the last hyphen in your character sets? 
As well as the . before the third character set?

-Steve

On Tuesday, August 20, 2002, at 11:11  AM, [EMAIL PROTECTED] wrote:

 I am trying an email verification function, like this:

  if (empty($useremail)) || !eregi(^[A-Za-z0-9\_-]+@[A-Za-z0-9\_-]
 +.[A-Za-z0-9\_-]+.*, $email))
   {
$errmsg .= The email address appears to be invalid\n;
   }

 But it will not work, on one server I get this error:
 Parse error: parse error in
 /home/virtual/site109/fst/var/www/html/auth_dealers/user_input2.php on 
 line
 70
 and on another server I get this error:
 Parse error: parse error, unexpected T_BOOLEAN_OR in
 /usr/local/apache/htdocs/auth_dealers/user_input2.php on line 70

 What do I need to do to fix this?

 --
 Chip Wiegand
 Computer Services
 Simrad, Inc
 www.simradusa.com
 [EMAIL PROTECTED]

 There is no reason anyone would want a computer in their home.
  --Ken Olson, president, chairman and founder of Digital Equipment
 Corporation, 1977
  (They why do I have 9? Somebody help me!)


 --
 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] what's wrong with this ereg?

2002-08-20 Thread chip . wiegand

Steve Cayford [EMAIL PROTECTED] wrote on 08/20/2002 10:28:46 AM:

 Well, one thing is you've got mismatched parentheses. You need another
 another opening paren right after the if.

 Also, don't you need to escape the last hyphen in your character sets?
 As well as the . before the third character set?

 -Steve

Got it fixed like this:

if (empty($useremail) || !eregi(^[A-Za-z0-9\.\_-]+@[A-Za-z0-9\_-]
+\.[A-Za-z0-9\_-]+$, $useremail))

--
Chip

 On Tuesday, August 20, 2002, at 11:11  AM, [EMAIL PROTECTED] wrote:

  I am trying an email verification function, like this:
 
   if (empty($useremail)) || !eregi(^[A-Za-z0-9\_-]+@[A-Za-z0-9\_-]
  +.[A-Za-z0-9\_-]+.*, $email))
{
 $errmsg .= The email address appears to be invalid\n;
}
 
  But it will not work, on one server I get this error:
  Parse error: parse error in
  /home/virtual/site109/fst/var/www/html/auth_dealers/user_input2.php on
  line
  70
  and on another server I get this error:
  Parse error: parse error, unexpected T_BOOLEAN_OR in
  /usr/local/apache/htdocs/auth_dealers/user_input2.php on line 70
 
  What do I need to do to fix this?
 
  --
  Chip Wiegand
  Computer Services
  Simrad, Inc
  www.simradusa.com
  [EMAIL PROTECTED]
 
  There is no reason anyone would want a computer in their home.
   --Ken Olson, president, chairman and founder of Digital Equipment
  Corporation, 1977
   (They why do I have 9? Somebody help me!)
 
 
  --
  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 Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] what's wrong with this?

2002-01-27 Thread Ali Nayeri

hi all

i've been trying this script for a day and i just can't figure out why it
doesn't work.  could someone check and see if there is something i did
wrong? the error is unknown function include_menu() which actually exist
in the menu.inc file.

this is the structure:
home.php
includes (folder)
  layout.inc
  menu.inc

thanks in advance

Ali



-- 
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] what's wrong with this?

2002-01-27 Thread Ali Nayeri

i'm not sure why the files didn't come through. i'll try again.

-Original Message-
From: Ali Nayeri [mailto:[EMAIL PROTECTED]]
Sent: January 27, 2002 8:18 PM
To: PHP Database Mailing List
Subject: [PHP-DB] what's wrong with this?


hi all

i've been trying this script for a day and i just can't figure out why it
doesn't work.  could someone check and see if there is something i did
wrong? the error is unknown function include_menu() which actually exist
in the menu.inc file.

this is the structure:
home.php
includes (folder)
  layout.inc
  menu.inc

thanks in advance

Ali




-- 
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] what's wrong with this?

2002-01-27 Thread Ali Nayeri

can't you attach files in this mailing list?  is there a special way? could
someone tell me.

Thanks

-Original Message-
From: Ali Nayeri [mailto:[EMAIL PROTECTED]]
Sent: January 27, 2002 8:27 PM
To: PHP Database Mailing List
Subject: RE: [PHP-DB] what's wrong with this?


i'm not sure why the files didn't come through. i'll try again.

-Original Message-
From: Ali Nayeri [mailto:[EMAIL PROTECTED]]
Sent: January 27, 2002 8:18 PM
To: PHP Database Mailing List
Subject: [PHP-DB] what's wrong with this?


hi all

i've been trying this script for a day and i just can't figure out why it
doesn't work.  could someone check and see if there is something i did
wrong? the error is unknown function include_menu() which actually exist
in the menu.inc file.

this is the structure:
home.php
includes (folder)
  layout.inc
  menu.inc

thanks in advance

Ali




_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


-- 
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] What's wrong?

2001-11-20 Thread Sergio Augusto Bitencourt Petrovcic

Ho there...I really wonder what's wrong with this script. The error is in
this line below:
if((count($info) != 1)  ($folder == $info[2])) echo tabletrtda
href= . $info[1] .  . $info[0] . /abr/td/tr/table;
The condition ($folder == $info[2]) is not working!
I hope you can help me!
Here's the code:

?php

$link_name = Tudo sobre automação;
$link_address = http://www.automacao.eng.br;;
$link_folder = faculdade;
$file = teste.txt;

function write($file,$link_name,$link_address,$link_folder) {
 $file=fopen($file,w);
 fwrite($file,$link_name|$link_address|$link_folder\n);
 fclose($file);
}

function read($file,$folder) {
 $file=fopen($file,r);
 while (!feof ($file)) {
  $buffer = fgets($file,1024);
  $info = explode(|,$buffer);
  if((count($info) != 1)  ($folder == $info[2])) echo tabletrtda
href= . $info[1] .  . $info[0] . /abr/td/tr/table;
 }
 fclose($file);
}

write($file,$link_name,$link_address,$link_folder);
read($file,faculdade);

?

Thanks!


-- 
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] What's wrong?

2001-11-20 Thread Dobromir Velev

Hi,
the most probable reason is that the file you're reading from was saved in a
different filesystem and the $info[2] has some newline characters at the
end.

You can use the trim() function to remove it. Than your expression will look
something like this
if(count($info) != 1  $folder == trim($info[2]))

HTH
Dobromir Velev

-Original Message-
From: Sergio Augusto Bitencourt Petrovcic [EMAIL PROTECTED]
To: [EMAIL PROTECTED] [EMAIL PROTECTED]
Date: Tuesday, November 20, 2001 13:58
Subject: [PHP-DB] What's wrong?


Ho there...I really wonder what's wrong with this script. The error is in
this line below:
if((count($info) != 1)  ($folder == $info[2])) echo tabletrtda
href= . $info[1] .  . $info[0] . /abr/td/tr/table;
The condition ($folder == $info[2]) is not working!
I hope you can help me!
Here's the code:

?php

$link_name = Tudo sobre automação;
$link_address = http://www.automacao.eng.br;;
$link_folder = faculdade;
$file = teste.txt;

function write($file,$link_name,$link_address,$link_folder) {
 $file=fopen($file,w);
 fwrite($file,$link_name|$link_address|$link_folder\n);
 fclose($file);
}

function read($file,$folder) {
 $file=fopen($file,r);
 while (!feof ($file)) {
  $buffer = fgets($file,1024);
  $info = explode(|,$buffer);
  if((count($info) != 1)  ($folder == $info[2])) echo tabletrtda
href= . $info[1] .  . $info[0] . /abr/td/tr/table;
 }
 fclose($file);
}

write($file,$link_name,$link_address,$link_folder);
read($file,faculdade);

?

Thanks!


--
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] What's wrong with my function? :(

2001-10-31 Thread Torrent

Tx.

Yep I have read it now and understood it better than the first time I read
this part of the manual (it's amazing how things make more sense when you
can apply them to what you are doing).

Jesse Goerz [EMAIL PROTECTED] wrote in message
0110301727.19453@reign">news:0110301727.19453@reign...
 On Tuesday 30 October 2001 15:49, TorrentUK wrote:
  Please could some take a look at this code and tell me why
  when I take my IF statements out of the function and put in
  them in the same place where I call the function from they
  work, but as soon as I replace them with the function name
  they don't?
 
  Appreciate any help.
  torrent
 
  Here's the code...

 Your variable is not in scope.  Either pass your variable as a
 reference in the function definition:
 function RatingFilter ($sql) {
 ...
 }

 or use the global keyword to bring your variable into scope:
 function RatingFilter () {
 global $sql;
 if ($br) {$sql.=  and beg_rate = '2';}
 ...
 }

 And follow the advice of Charles and read up on it so you know
 how they are different.




-- 
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] What's wrong with my function? :(

2001-10-30 Thread TorrentUK

Please could some take a look at this code and tell me why when I take my IF
statements out of the function and put in them in the same place where I
call the function from they work, but as soon as I replace them with the
function name they don't?

Appreciate any help.
torrent

Here's the code...

// Define the rating's filter
?php
 function RatingFilter () {
  if ($br) {$sql.=  and beg_rate = '2';}

  if ($ir) {$sql.=  and int_rate = '2';}

  if ($ar) {$sql.=  and adv_rate = '2';}

  if ($sr) {$sql.=  and sbd_rate = '2';}

 }
?


if ($search) {

 include ('logon-inc.php');

 $sql = SELECT rsrt_name, ctry_name FROM resort_tbl WHERE
ctry_name='$country[0]';

 RatingFilter(); --- If I put 'if' statement here instead it works


 for ($n=1; count($country)  $n; $n++){

  $sql.=  or ctry_name='$country[$n]';

  RatingFilter(); -- Or here
 }
 .
 .
 .
 .
 }




-- 
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] What's wrong with my function? :(

2001-10-30 Thread Charles F. McKnight



On Tue, 30 Oct 2001, TorrentUK wrote:

SNIP

you either need to pass the variables to the function or use global
variables in the function see
http://www.php.net/manual/en/language.variables.scope.php
 
 Here's the code...
 
 // Define the rating's filter
 ?php
  function RatingFilter () {
   if ($br) {$sql.=  and beg_rate = '2';}
 
   if ($ir) {$sql.=  and int_rate = '2';}
 
   if ($ar) {$sql.=  and adv_rate = '2';}
 
   if ($sr) {$sql.=  and sbd_rate = '2';}
 
  }
 ?
 
 
 if ($search) {
 
  include ('logon-inc.php');
 
  $sql = SELECT rsrt_name, ctry_name FROM resort_tbl WHERE
 ctry_name='$country[0]';
 
  RatingFilter(); --- If I put 'if' statement here instead it works
 
 
  for ($n=1; count($country)  $n; $n++){
 
   $sql.=  or ctry_name='$country[$n]';
 
   RatingFilter(); -- Or here
  }
  .
  .
  .
  .
  }
 
 
 
 
 

-- 
Charles F. McKnight   IRC: sokudo  | Doubt is not a pleasant condition, but
[EMAIL PROTECTED]  ICQ: 2794793 | certainty is absurd.
[EMAIL PROTECTED] PGP: 0x20A5BCE5  | - Voltaire
[ http://chucksays.mywebsitesucks.com ]-


-- 
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] What's wrong with my function? :(

2001-10-30 Thread Leotta, Natalie (NCI/IMS)

I'm new to PHP but one thing I think might be happening is that maybe the
changes aren't being made to a global (I'm a Java programmer) $sql so they
aren't being kept.  Does it actually break or is it not appending the
additional string?  I'd try printing out the $sql and see what you're
getting - possibly at different stages of the program - like before and
after you call your function.

Good luck!

-Natalie

 -Original Message-
 From: TorrentUK [SMTP:[EMAIL PROTECTED]]
 Sent: Tuesday, October 30, 2001 3:50 PM
 To:   [EMAIL PROTECTED]
 Subject:  [PHP-DB] What's wrong with my function? :(
 
 Please could some take a look at this code and tell me why when I take my
 IF
 statements out of the function and put in them in the same place where I
 call the function from they work, but as soon as I replace them with the
 function name they don't?
 
 Appreciate any help.
 torrent
 
 Here's the code...
 
 // Define the rating's filter
 ?php
  function RatingFilter () {
   if ($br) {$sql.=  and beg_rate = '2';}
 
   if ($ir) {$sql.=  and int_rate = '2';}
 
   if ($ar) {$sql.=  and adv_rate = '2';}
 
   if ($sr) {$sql.=  and sbd_rate = '2';}
 
  }
 ?
 
 
 if ($search) {
 
  include ('logon-inc.php');
 
  $sql = SELECT rsrt_name, ctry_name FROM resort_tbl WHERE
 ctry_name='$country[0]';
 
  RatingFilter(); --- If I put 'if' statement here instead it works
 
 
  for ($n=1; count($country)  $n; $n++){
 
   $sql.=  or ctry_name='$country[$n]';
 
   RatingFilter(); -- Or here
  }
  .
  .
  .
  .
  }
 
 
 
 
 -- 
 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] What's wrong with my function? :(

2001-10-30 Thread TorrentUK

Yep, that'll be it.
Thanks for the help. :)

torrent

Charles F. McKnight [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...


 On Tue, 30 Oct 2001, TorrentUK wrote:

 SNIP

 you either need to pass the variables to the function or use global
 variables in the function see
 http://www.php.net/manual/en/language.variables.scope.php

  Here's the code...
 
  // Define the rating's filter
  ?php
   function RatingFilter () {
if ($br) {$sql.=  and beg_rate = '2';}
 
if ($ir) {$sql.=  and int_rate = '2';}
 
if ($ar) {$sql.=  and adv_rate = '2';}
 
if ($sr) {$sql.=  and sbd_rate = '2';}
 
   }
  ?
 
 
  if ($search) {
 
   include ('logon-inc.php');
 
   $sql = SELECT rsrt_name, ctry_name FROM resort_tbl WHERE
  ctry_name='$country[0]';
 
   RatingFilter(); --- If I put 'if' statement here instead it works
 
 
   for ($n=1; count($country)  $n; $n++){
 
$sql.=  or ctry_name='$country[$n]';
 
RatingFilter(); -- Or here
   }
   .
   .
   .
   .
   }
 
 
 
 
 

 --
 Charles F. McKnight   IRC: sokudo  | Doubt is not a pleasant
condition, but
 [EMAIL PROTECTED]  ICQ: 2794793 | certainty is absurd.
 [EMAIL PROTECTED] PGP: 0x20A5BCE5  | -
Voltaire
 [
http://chucksays.mywebsitesucks.com ]-




-- 
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] What's wrong with this code?

2001-03-26 Thread Emir Musabasic

Hi,

I really need help, I wrote a function so that I can
call for db user/password in an include file. It looks
like this:

// Connect to the database
function db_connect(){
global $MYSQL_USERNAME, $MYSQL_PASSWORD, $DB,
$HOST;
$db =
mysql_connect("$HOST","$MYSQL_USERNAME","$MYSQL_PASSWORD");
mysql_select_db("$DB",$db);
}

I have user/password/host variables inside a config
file but for some reason when I include this into a
php page when I test it, I get:

Fatal error: Cannot redeclare db_connect() in
/www/affiliate/include/functions.inc on line 7.

Am I missing something because everything looks good
to me.

Emir.

__
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

-- 
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] What's wrong with this code?

2001-03-26 Thread Brunner, Daniel

Hello...

Try mysql_pconnect instead

Dan



 --
 From: Emir Musabasic
 Sent: Monday, March 26, 2001 9:34 AM
 To:   [EMAIL PROTECTED]
 Subject:  [PHP-DB] What's wrong with this code?
 
 Hi,
 
 I really need help, I wrote a function so that I can
 call for db user/password in an include file. It looks
 like this:
 
 // Connect to the database
 function db_connect(){
 global $MYSQL_USERNAME, $MYSQL_PASSWORD, $DB,
 $HOST;
 $db =
 mysql_connect("$HOST","$MYSQL_USERNAME","$MYSQL_PASSWORD");
 mysql_select_db("$DB",$db);
 }
 
 I have user/password/host variables inside a config
 file but for some reason when I include this into a
 php page when I test it, I get:
 
 Fatal error: Cannot redeclare db_connect() in
 /www/affiliate/include/functions.inc on line 7.
 
 Am I missing something because everything looks good
 to me.
 
 Emir.
 
 __
 Do You Yahoo!?
 Get email at your own domain with Yahoo! Mail. 
 http://personal.mail.yahoo.com/
 
 -- 
 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] What's wrong with this code?

2001-03-26 Thread CC Zona

In article [EMAIL PROTECTED],
 [EMAIL PROTECTED] (Emir Musabasic) wrote:

 I have user/password/host variables inside a config
 file but for some reason when I include this into a
 php page when I test it, I get:
 
 Fatal error: Cannot redeclare db_connect() in
 /www/affiliate/include/functions.inc on line 7.
 
 Am I missing something because everything looks good
 to me.

Try using include_once() instead of include().  You're probably 
inadvertantly re-including the file.  In general, except where you're 
deliberately making multiple includes of the same file, it's a good idea to 
get in the habit of using include_once() or require_once() to save yourself 
from surprises like this.

-- 
CC

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