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