|
|
|
|
![]() ![]() |
Feb 2 2005, 06:20 AM
Post
#1
|
|
|
Newbie [ Level 2 ] 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??? |
|
|
|
Feb 2 2005, 06:42 AM
Post
#2
|
|
|
Advanced Member 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. |
|
|
|
Feb 2 2005, 07:00 AM
Post
#3
|
|
|
Newbie [ Level 2 ] Group: [HOSTED] Posts: 25 Joined: 5-September 04 From: MEXICO DF Member No.: 260 |
doesn't function....
but thank u so much avalon |
|
|
|
Feb 2 2005, 07:09 AM
Post
#4
|
|
|
Advanced Member 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. |
|
|
|
Feb 2 2005, 09:25 AM
Post
#5
|
|
|
PESTICIDAL MANIAC 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 |
|
|
|
Feb 2 2005, 11:04 AM
Post
#6
|
|
|
PsYcheDeLiC dR3aMeR 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...
|
|
|
|
Feb 2 2005, 11:14 AM
Post
#7
|
|
|
PESTICIDAL MANIAC 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 |
|
|
|
Feb 2 2005, 11:43 AM
Post
#8
|
|
|
PsYcheDeLiC dR3aMeR Group: Admin Posts: 2,242 Joined: 29-January 05 From: Nakorn Chaisri, Thailand Member No.: 2,411 myCENTs:84.36 |
Righton
|
|
|
|
Feb 2 2005, 11:56 AM
Post
#9
|
|
|
Administrator 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 |
|
|
|
Feb 2 2005, 06:16 PM
Post
#10
|
|
|
Newbie [ Level 2 ] 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 Ó 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 thank u guys ... greetings from México City |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 5th December 2008 - 01:16 AM |