Welcome Guest ( Log In | Register )



2 Pages V   1 2 >  
Reply to this topicStart new topic
> MySQL Query, some help needed
panquetofobia
post Feb 2 2005, 06:20 AM
Post #1


Newbie [ Level 2 ]
Group Icon

Group: [HOSTED]
Posts: 25
Joined: 5-September 04
From: MEXICO DF
Member No.: 260



i dunno why this query doesn't function..

CODE

$sql="SELECT count(*) FROM participantes,sancionados WHERE participantes.No_Ficha = '$no_ficha' or sancionados.No_Ficha='$no_ficha'";
$query=($sql);



any suggestion???
Go to the top of the page
 
+Quote Post
avalon
post Feb 2 2005, 06:42 AM
Post #2


Advanced Member
Group Icon

Group: Members
Posts: 160
Joined: 27-October 04
Member No.: 1,260



CODE
$sql="SELECT count(*) FROM participantes, sancionados WHERE `participantes`.`No_Ficha` = '$no_ficha' AND `sancionados`.`No_Ficha`='$no_ficha'";
$query=$sql;


try the above code.
Go to the top of the page
 
+Quote Post
panquetofobia
post Feb 2 2005, 07:00 AM
Post #3


Newbie [ Level 2 ]
Group Icon

Group: [HOSTED]
Posts: 25
Joined: 5-September 04
From: MEXICO DF
Member No.: 260



doesn't function....

but thank u so much avalon wink.gif
Go to the top of the page
 
+Quote Post
avalon
post Feb 2 2005, 07:09 AM
Post #4


Advanced Member
Group Icon

Group: Members
Posts: 160
Joined: 27-October 04
Member No.: 1,260



Try this:-

CODE
$sql="SELECT count(*) FROM `participantes`, `sancionados` WHERE `participantes`.`No_Ficha` = '".$no_ficha."' AND `sancionados`.`No_Ficha`='".$no_ficha."'";
$query=$sql;


or this:-

CODE
$sql="SELECT count(*) FROM `participantes` WHERE `No_Ficha` = '".$no_ficha."'";
$query=$sql;


if it still doesn't not work, i will have to get back to you later today or tomorrow.
Go to the top of the page
 
+Quote Post
mastercomputers
post Feb 2 2005, 09:25 AM
Post #5


PESTICIDAL MANIAC
Group Icon

Group: Members
Posts: 626
Joined: 1-September 04
From: Auckland, New Zealand
Member No.: 27



Maybe you're not doing the query, you're just setting $query to $sql, you have to use $query = mysql_query($sql) or die("Maybe you were right?");

Other than this, I can't see a problem.


MC
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post Feb 2 2005, 11:04 AM
Post #6


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411
myCENTs:84.36



QUOTE
$sql="SELECT count(*) FROM participantes,sancionados WHERE participantes.No_Ficha = '$no_ficha' or sancionados.No_Ficha='$no_ficha'";
$query=($sql);


See from your query, I figure you are trying to match up the contents of the variable $no_ficha with the table columns participantes.No_Ficha and sancionados.No_Ficha. the query is perfectly fine and wouldn't even need the open-close quotes (``) around the table/column names as shown here.
QUOTE
`participantes`, `sancionados` WHERE `participantes`.`No_Ficha` = '".$no_ficha."' AND `sancionados`.`No_Ficha`='".$no_ficha."'";


My guess is where you are going wrong is the open-close quotes ('') around the $no_ficha.... if you want to match the contents of $no_ficha with your table columns, then you have to enclose $no_ficha in double quotes ("$no_ficha") for PHP to be able to parse it as a variable and extract and use its value. Between single quotes, $no_ficha is treated as a string and you query is trying to find a string called $no_ficha in your tables... Try with double quotes and see....

I think breaking up the query like this would help:

$sql="SELECT count(*) FROM participantes,sancionados WHERE participantes.No_Ficha =" . "$no_ficha" . "or sancionados.No_Ficha = " . "$no_ficha";

...
...
And next check your syntax and add what mastercomputers wrote...
QUOTE
Maybe you're not doing the query, you're just setting $query to $sql, you have to use $query = mysql_query($sql) or die("Maybe you were right?");
- coz it seems from your syntax that you aren't doing to query at all...
Go to the top of the page
 
+Quote Post
mastercomputers
post Feb 2 2005, 11:14 AM
Post #7


PESTICIDAL MANIAC
Group Icon

Group: Members
Posts: 626
Joined: 1-September 04
From: Auckland, New Zealand
Member No.: 27



I see where you're coming from microscopic^earthling and I did too pick this up.

The only thing if I can explain it to you is that the single quotes are inside double quotes, meaning they play no importance other than being single quotes in a double quoted string.

Because the double quoted string is used and there's no closing prior the single quotes, the variables will be processed by PHP as variables inside that double quoted string and not as if they were singluarly quoted.

e.g $double_quoted = " '$hello' "; produces 'the_element_contained_in_hello' with the quotes. If it were only $single_quoted = ' "$hello" '; produces only "$hello", with the double quotes around it and not what's contained in the variable $hello.

You need to use those quotes in those statements though, so never leave them off.

MC
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post Feb 2 2005, 11:43 AM
Post #8


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411
myCENTs:84.36



Righton smile.gif thanks for clearing it up...it got a little fuzzy seeing so many quotes flying around wink.gif
Go to the top of the page
 
+Quote Post
OpaQue
post Feb 2 2005, 11:56 AM
Post #9


Administrator
Group Icon

Group: Admin
Posts: 467
Joined: 26-August 04
Member No.: 1
myCENTs:85.82



// Added Aliases just to avoid those big lengthy names
CODE

$sql="
SELECT count(*)
FROM participantes AS a, sancionados AS b
WHERE a.No_Ficha = '$no_ficha'
OR b.No_Ficha='$no_ficha';
";

$sql_result = mysql_query($sql,$connection) || die(mysql_error());

Check the Following,
The Column names are Case-sensitive and they are properly written.
If the things still dont work, Would you please put down the error statement reported by the "mysql_error()" function.

-OpaQue
Go to the top of the page
 
+Quote Post
panquetofobia
post Feb 2 2005, 06:16 PM
Post #10


Newbie [ Level 2 ]
Group Icon

Group: [HOSTED]
Posts: 25
Joined: 5-September 04
From: MEXICO DF
Member No.: 260



a part of my code...

CODE

$sqlcheck="SELECT count(*) FROM participantes AS a, sancionados AS b WHERE a.No_Ficha = '$no_ficha' OR b.No_Ficha='$no_ficha';";
  $querycheck=mysql_query($sqlcheck) || die(mysql_error());;

if(@mysql_result($querycheck,0,0)>0)
   {
    $merror.="<p style=\"color:#990000; font-weight:bold\">JUGADOR YA REGISTRADO &Oacute; SANCIONADO <img src=\"./imgs/error.gif\" alt=\"\"></p>";
   }
   else
   {
$sql="UPDATE equipos SET integrantes_restantes='$integrantesr' where Centro_de_Trabajo='$centro_trabajo' and Deporte='$deporte'";
$query=mysql_query($sql);
   $sql="INSERT INTO participantes VALUES (0,'$nombre','$ape1','$ape2','$no_ficha','$situacionc','$talla','$anios','$deporte','$rama','$centro_trabajo','$enc_reg','$fecha'";
   $query=mysql_query($sql);
   @$merror.="<p>Jugador ".$nombre." ".$ape1." ".$ape2." <strong>Registrado</strong>  <img src=\"./imgs/oki.gif\" alt=\"\"></p>";
   }  



the insert query doesn't function either sad.gif ...

thank u guys ...


greetings from México City
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. MySQL - Trouble With Bulk Insert Statements(3)
  2. MySQL Realtime Replication(4)
  3. Recover Tables From A MySQL .frm File(8)
  4. Mirror My MySQL Database To Another Mysql Server(4)
  5. How To Connect MySQL With Flash?(8)
  6. MySQL Output Database Question(18)
  7. MySQL, Multiple Tables(24)
  8. Navcat For MySQL(9)
  9. Permission Problem With Mysql Database Creation(8)
  10. Mysql And Php(15)
  11. Login System Using A Mysql Db(5)
  12. Oracle Vs. Mysql Vs. Postgresql(9)
  13. Subqueries In Mysql(1)
  14. Apache Php With Mysql On Windows [solved](9)
  15. Mysql - So Hard(14)
  1. Mysql Problem(1)
  2. Sun Bought Mysql(6)
  3. Mysql Backup With Another Address?(4)
  4. I Have An Error With My Mysql Connection(7)
  5. Mysql And User File_priv(0)
  6. Mysql Database Management(1)
  7. Mysql Database Entry By Excel Sheets(2)
  8. Mysql On Computer(9)
  9. Space Needed For Database(10)
  10. Any Website Provide Free Host Mysql Host?(4)
  11. Mysql Multiple Tables(1)
  12. Mysql Overhead(3)
  13. Login System(6)


 



- Lo-Fi Version Time is now: 5th December 2008 - 01:16 AM