[PHP] Query bug

2002-03-27 Thread Daniel Ferreira Castro

I have a problem.

I have those tables on my database:
mysql use projeto;
Database changed

mysql show tables;
+---+
| Tables_in_projeto |
+---+
| ALGORITMO |
| ATAS  |
| MANUAIS   |
| PROJETO   |
| REFERENCIAS   |
| RELATORIOS|
+---+

mysql describe ALGORITMO;
+-+--+--+-+-++
| Field   | Type | Null | Key | Default | Extra  |
+-+--+--+-+-++
| id  | int(11)  |  | PRI | NULL| auto_increment |
| id_proj | int(11)  | YES  | | NULL||
| nome| varchar(30)  | YES  | | NULL||
| arquivo | varchar(100) | YES  | | NULL||
| des | tinyint(4)   | YES  | | NULL||
| eng | tinyint(4)   | YES  | | NULL||
+-+--+--+-+-++
6 rows in set (0.00 sec)

mysql describe ATAS;
+-+--+--+-+-++
| Field   | Type | Null | Key | Default | Extra  |
+-+--+--+-+-++
| id  | int(11)  |  | PRI | NULL| auto_increment |
| id_proj | int(11)  | YES  | | NULL||
| nome| varchar(30)  | YES  | | NULL||
| arquivo | varchar(120) | YES  | | NULL||
| des | tinyint(4)   | YES  | | NULL||
| eng | tinyint(4)   | YES  | | NULL||
+-+--+--+-+-++
6 rows in set (0.00 sec)

mysql describe MANUAIS;
+-+--+--+-+-++
| Field   | Type | Null | Key | Default | Extra  |
+-+--+--+-+-++
| id  | int(11)  |  | PRI | NULL| auto_increment |
| id_proj | int(11)  | YES  | | NULL||
| nome| varchar(30)  | YES  | | NULL||
| arquivo | varchar(100) | YES  | | NULL||
| des | tinyint(4)   | YES  | | NULL||
| eng | tinyint(4)   | YES  | | NULL||
+-+--+--+-+-++
6 rows in set (0.00 sec)

mysql describe REFERENCIAS;
+-+--+--+-+-++
| Field   | Type | Null | Key | Default | Extra  |
+-+--+--+-+-++
| id  | int(11)  |  | PRI | NULL| auto_increment |
| id_proj | int(11)  | YES  | | NULL||
| nome| varchar(30)  | YES  | | NULL||
| arquivo | varchar(100) | YES  | | NULL||
| des | tinyint(4)   | YES  | | NULL||
| eng | tinyint(4)   | YES  | | NULL||
+-+--+--+-+-++
6 rows in set (0.02 sec)

mysql describe RELATORIOS;
+-+--+--+-+-++
| Field   | Type | Null | Key | Default | Extra  |
+-+--+--+-+-++
| id  | int(11)  |  | PRI | NULL| auto_increment |
| id_proj | int(11)  | YES  | | NULL||
| nome| varchar(30)  | YES  | | NULL||
| arquivo | varchar(100) | YES  | | NULL||
| des | tinyint(4)   | YES  | | NULL||
| eng | tinyint(4)   | YES  | | NULL||
+-+--+--+-+-++

I want to select the fields nome,id_proj,arquivo FROM ALGORITMO and ATAS.  But when I 
use the query below, I receive the error ERROR 1052: Column: 'nome' in field list is 
ambiguous.  What is wrong on my query?

query: SELECT nome,id_proj,arquivo FROM ALGORITMO,ATAS WHERE id_proj=0 AND eng=1 OR 
nome=teste  OR nome=de  OR nome=parse;

Thank you

Daniel Ferreira Castro
[EMAIL PROTECTED]



Re: [PHP] Query bug

2002-03-27 Thread Erik Price


On Wednesday, March 27, 2002, at 04:00  PM, Daniel Ferreira Castro wrote:

 I want to select the fields nome,id_proj,arquivo FROM ALGORITMO and
 ATAS.  But when I use the query below, I receive the error ERROR 1052:
 Column: 'nome' in field list is ambiguous.  What is wrong on my query?

 query: SELECT nome,id_proj,arquivo FROM ALGORITMO,ATAS WHERE id_proj=0
 AND eng=1 OR nome=teste  OR nome=de  OR nome=parse;

Daniel, try specifying which table you want the 'nome' column to be used 
in -- the ambiguous part is that many of the tables you are selecting 
FROM have a 'nome' column.  Do it like this:

SELECT ALGORITMO.nome,
ALGORITMO.id_proj,
ATAS.arquivo
FROM   ALGORITMO,
ATAS
WHERE  ALGORITMO.id_proj=0
ANDALGORITMO.eng=1
OR ALGORITMO.nome=teste
OR ATAS.nome=de
OR ATAS.nome=parse;

Obviously, I have no idea how you want your query to look, so be sure to 
customize it for your needs, but this demonstrates what you need to do: 
Explicitly state the table whose column you want to access.


Erik






Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


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




Re: [PHP] Query bug

2002-03-27 Thread Daniel Ferreira Castro

This way works, but not the way i would like to.
Because it selects just the fields nome,id_proj and arquivo from the
table ALGORITMO, and here my goal is to select those fileds of ALGORITMO and
ATAS.


Erik Price [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 On Wednesday, March 27, 2002, at 04:00  PM, Daniel Ferreira Castro wrote:

  I want to select the fields nome,id_proj,arquivo FROM ALGORITMO and
  ATAS.  But when I use the query below, I receive the error ERROR 1052:
  Column: 'nome' in field list is ambiguous.  What is wrong on my query?
 
  query: SELECT nome,id_proj,arquivo FROM ALGORITMO,ATAS WHERE id_proj=0
  AND eng=1 OR nome=teste  OR nome=de  OR nome=parse;

 Daniel, try specifying which table you want the 'nome' column to be used
 in -- the ambiguous part is that many of the tables you are selecting
 FROM have a 'nome' column.  Do it like this:

 SELECT ALGORITMO.nome,
 ALGORITMO.id_proj,
 ATAS.arquivo
 FROM   ALGORITMO,
 ATAS
 WHERE  ALGORITMO.id_proj=0
 ANDALGORITMO.eng=1
 OR ALGORITMO.nome=teste
 OR ATAS.nome=de
 OR ATAS.nome=parse;

 Obviously, I have no idea how you want your query to look, so be sure to
 customize it for your needs, but this demonstrates what you need to do:
 Explicitly state the table whose column you want to access.


 Erik




 

 Erik Price
 Web Developer Temp
 Media Lab, H.H. Brown
 [EMAIL PROTECTED]




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




Re: [PHP] Query bug

2002-03-27 Thread Erik Price


On Wednesday, March 27, 2002, at 04:28  PM, Daniel Ferreira Castro wrote:

 This way works, but not the way i would like to.
 Because it selects just the fields nome,id_proj and arquivo from 
 the
 table ALGORITMO, and here my goal is to select those fileds of 
 ALGORITMO and
 ATAS.

Then why not just add an additional lines?

SELECT ALGORITMO.nome,
 ALGORITMO.id_proj,
 ALGORITMO.arquivo,
 ATAS.nome,
 ATAS.id_proj,
 ATAS.arquivo
FROM   ALGORITMO,
 ATAS
WHERE  ALGORITMO.id_proj=0
ANDALGORITMO.eng=1
OR ALGORITMO.nome=teste
OR ATAS.nome=de
OR ATAS.nome=parse;
OR


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




[PHP] Query bug, what is wrong?

2002-03-08 Thread Daniel F. Castro

?php
   $qname  = $HTTP_POST_VARS['ct_nome'];
   $qkey   = $HTTP_POST_VARS['ct_kw'];
   $qdia   = $HTTP_POST_VARS['ct_dia'];
   $qmes   = $HTTP_POST_VARS['ct_mes'];
   $qano   = $HTTP_POST_VARS['ct_ano'];
   $qautor = $HTTP_POST_VARS['ct_autor'];
   $qeng   = $HTTP_POST_VARS['cS_eng'];
   $qdes   = $HTTP_POST_VARS['cS_des'];
   $qFILE  = FILES;
   $host   = localhost;
   //Database Conection
   $link = mysql_connect($host,root,root)
 or die(Not possible to connect);
   print(Connection OK);
   //Database Selection
   mysql_select_db(test)
 or die(mysql_error());
   print(Selection OK);
   $query = INSERT INTO projeto (nome,setor,arquivo,status) VALUES
 ($qname,$qdes,$qFILE,'ok');
   print $qname;
   print $qkey;
   print $qautor;
   print $qdia/$qmes/$qano;
   //My Query
   mysql_query ($query)
 or Die (mysql_error());
   echo Projecto registered;

   // Closing connection
   mysql_close($link);
 ?

 Thanks you

 Daniel Castro




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




Re: [PHP] Query bug, what is wrong?

2002-03-08 Thread Jason Wong

On Friday 08 March 2002 21:29, Daniel F. Castro wrote:
 ?php
$qname  = $HTTP_POST_VARS['ct_nome'];
$qkey   = $HTTP_POST_VARS['ct_kw'];
$qdia   = $HTTP_POST_VARS['ct_dia'];
$qmes   = $HTTP_POST_VARS['ct_mes'];



[snip]

What's wrong with it? What was the error msg if any?


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk


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




Re: [PHP] Query bug, what is wrong?

2002-03-08 Thread Daniel F. Castro

The error msg is

You have an error in your SQL syntax near 'ARQUIVO,NULL)' at line 1

Daniel Ferreira Castro
Jason Wong [EMAIL PROTECTED] escreveu na mensagem
news:[EMAIL PROTECTED]...
 On Friday 08 March 2002 21:29, Daniel F. Castro wrote:
  ?php
 $qname  = $HTTP_POST_VARS['ct_nome'];
 $qkey   = $HTTP_POST_VARS['ct_kw'];
 $qdia   = $HTTP_POST_VARS['ct_dia'];
 $qmes   = $HTTP_POST_VARS['ct_mes'];



 [snip]

 What's wrong with it? What was the error msg if any?


 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk




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




Re: [PHP] Query bug, what is wrong?

2002-03-08 Thread Jason Wong

On Friday 08 March 2002 21:56, you wrote:
 The error msg is

 You have an error in your SQL syntax near 'ARQUIVO,NULL)' at line 1


Try entering that query into mysql at the command line. Does it work?


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk

/*
Mark's Dental-Chair Discovery:
Dentists are incapable of asking questions that require a
simple yes or no answer.
*/

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




RE: [PHP] Query bug, what is wrong?

2002-03-08 Thread Robert V. Zwink

You probably need to wrap the strings you are trying to input with quotation
marks.

Try modifying this line  (add \) :
   $query = INSERT INTO projeto (nome,setor,arquivo,status) VALUES
 (\$qname\,\$qdes\,\$qFILE\,'ok');

Robert Zwink
http://www.zwink.net/daid.php


-Original Message-
From: Daniel F. Castro [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 08, 2002 8:29 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Query bug, what is wrong?


?php
   $qname  = $HTTP_POST_VARS['ct_nome'];
   $qkey   = $HTTP_POST_VARS['ct_kw'];
   $qdia   = $HTTP_POST_VARS['ct_dia'];
   $qmes   = $HTTP_POST_VARS['ct_mes'];
   $qano   = $HTTP_POST_VARS['ct_ano'];
   $qautor = $HTTP_POST_VARS['ct_autor'];
   $qeng   = $HTTP_POST_VARS['cS_eng'];
   $qdes   = $HTTP_POST_VARS['cS_des'];
   $qFILE  = FILES;
   $host   = localhost;
   //Database Conection
   $link = mysql_connect($host,root,root)
 or die(Not possible to connect);
   print(Connection OK);
   //Database Selection
   mysql_select_db(test)
 or die(mysql_error());
   print(Selection OK);
   $query = INSERT INTO projeto (nome,setor,arquivo,status) VALUES
 ($qname,$qdes,$qFILE,'ok');
   print $qname;
   print $qkey;
   print $qautor;
   print $qdia/$qmes/$qano;
   //My Query
   mysql_query ($query)
 or Die (mysql_error());
   echo Projecto registered;

   // Closing connection
   mysql_close($link);
 ?

 Thanks you

 Daniel Castro




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


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




Re: [PHP] Query bug, what is wrong?

2002-03-08 Thread hugh danaher

I think it should be single quote marks around the variables like you've
used around the ok:

$query = INSERT INTO projeto (nome,setor,arquivo,status) VALUES
  ('$qname','$qdes','$qFILE','ok');

Hope this helps,
Hugh

- Original Message -
From: Robert V. Zwink [EMAIL PROTECTED]
To: Daniel F. Castro [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Friday, March 08, 2002 6:22 AM
Subject: RE: [PHP] Query bug, what is wrong?


 You probably need to wrap the strings you are trying to input with
quotation
 marks.

 Try modifying this line  (add \) :
$query = INSERT INTO projeto (nome,setor,arquivo,status) VALUES
  (\$qname\,\$qdes\,\$qFILE\,'ok');

 Robert Zwink
 http://www.zwink.net/daid.php


 -Original Message-
 From: Daniel F. Castro [mailto:[EMAIL PROTECTED]]
 Sent: Friday, March 08, 2002 8:29 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Query bug, what is wrong?


 ?php
$qname  = $HTTP_POST_VARS['ct_nome'];
$qkey   = $HTTP_POST_VARS['ct_kw'];
$qdia   = $HTTP_POST_VARS['ct_dia'];
$qmes   = $HTTP_POST_VARS['ct_mes'];
$qano   = $HTTP_POST_VARS['ct_ano'];
$qautor = $HTTP_POST_VARS['ct_autor'];
$qeng   = $HTTP_POST_VARS['cS_eng'];
$qdes   = $HTTP_POST_VARS['cS_des'];
$qFILE  = FILES;
$host   = localhost;
//Database Conection
$link = mysql_connect($host,root,root)
  or die(Not possible to connect);
print(Connection OK);
//Database Selection
mysql_select_db(test)
  or die(mysql_error());
print(Selection OK);
$query = INSERT INTO projeto (nome,setor,arquivo,status) VALUES
  ($qname,$qdes,$qFILE,'ok');
print $qname;
print $qkey;
print $qautor;
print $qdia/$qmes/$qano;
//My Query
mysql_query ($query)
  or Die (mysql_error());
echo Projecto registered;

// Closing connection
mysql_close($link);
  ?

  Thanks you

  Daniel Castro




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


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



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