473,378 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

SQL wont display results

matheussousuke
249 100+
Well, the page is not displaying the sql results, perhaps there is something wrong in this line, but I still dont know how to fix:



Expand|Select|Wrap|Line Numbers
  1. echo "<tr bgcolor=\"$col\"><td><a class=TN href=\"javascript:popUp('preview.php?uname=$a1[uname]&ename=$ename')\"> $a2[0] $a2[1]</a></td><td> $a1[clname] </td></tr>";
  2.  
Is it the
Expand|Select|Wrap|Line Numbers
  1.  $a2[0] $a2[1]
part?




The code:

Expand|Select|Wrap|Line Numbers
  1. {
  2.  
  3.     $q2 = "select fname, lname from job_seeker_info where uname = \"$a1[uname]\" ";
  4.  
  5.     $r2 = mysql_query($q2) or die(mysql_error());
  6.  
  7.     $a2 = mysql_fetch_array($r2);
  8.  
  9.  
  10.  
  11.      if($col == "cococo")
  12.  
  13.         { 
  14.  
  15.          $col = "dddddd"; 
  16.  
  17.         }
  18.  
  19.                   else
  20.  
  21.         { 
  22.  
  23.         $col = "cococo"; 
  24.  
  25.         } 
  26.  
  27.  
  28.  
  29.     echo "<tr bgcolor=\"$col\"><td><a class=TN href=\"javascript:popUp('preview.php?uname=$a1[uname]&ename=$ename')\"> $a2[0] $a2[1]</a></td><td> $a1[clname] </td></tr>";
  30.  
  31. }
  32.  
If you want the full code, let me know.
Dec 2 '11 #1
36 2125
matheussousuke
249 100+
Please, someone, I know it's friday, but...
Dec 2 '11 #2
zorgi
431 Expert 256MB
Quick look and this is what I see:

$a1[uname] should probably be $a1['uname'] lines 3 & 29
$a1[clname] should probably be $a1['clname'] line 29
Dec 2 '11 #3
matheussousuke
249 100+
I put the quotes, and now I get this:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/sitee/public_html/employers/employers15.php on line 83
Dec 2 '11 #4
zorgi
431 Expert 256MB
Its probably because of the way you construct your query string. What is on line 83?
Dec 2 '11 #5
matheussousuke
249 100+
lol, on line 83 it's the line I altered.

Expand|Select|Wrap|Line Numbers
  1. uname=$a1['uname']&ename=$ename')\"> $a2[0] $a2[1]
Dec 2 '11 #6
zorgi
431 Expert 256MB
uname=$a1['uname']&ename=$ename'

should be

uname=".$a1['uname']."&ename=$ename'
Dec 3 '11 #7
matheussousuke
249 100+
I did this:

Expand|Select|Wrap|Line Numbers
  1.     echo "<tr bgcolor=\"$col\"><td><a class=TN href=\"javascript:popUp('preview.php?uname=".$a1['uname']."&ename=$ename')\"> $a2[0] $a2[1]</a></td><td> $a1[clname] </td></tr>";
  2.  
  3. }
It didnt work and the part .$a1['uname']. changed color, showing the code is wrong. =/
Dec 3 '11 #8
zorgi
431 Expert 256MB
You might want to have a look at String Operators because you did same mistake on the same line more than once.
Dec 3 '11 #9
matheussousuke
249 100+
I've read, but it's very basic, didn't find the solution for my quotes issue.
Dec 3 '11 #10
matheussousuke
249 100+
What if it's not that line, is this part correct?


Expand|Select|Wrap|Line Numbers
  1. {
  2.  
  3.     $q2 = "select fname, lname from job_seeker_info where uname = \"$a1[uname]\" ";
  4.  
  5.     $r2 = mysql_query($q2) or die(mysql_error());
  6.  
  7.     $a2 = mysql_fetch_array($r2);
  8.  
  9.  
  10.  
  11.      if($col == "cococo")
  12.  
  13.         { 
  14.  
  15.          $col = "dddddd"; 
  16.  
  17.         }
  18.  
  19.                   else
  20.  
  21.         { 
  22.  
  23.         $col = "cococo"; 
  24.  
  25.         } 
  26.  
Dec 3 '11 #11
zorgi
431 Expert 256MB
I agree, it is very basic, but you didn't apply those basic principles to your code. Example:
Expand|Select|Wrap|Line Numbers
  1. $a = array("uname" => "matheussousuke", "sname" => "surname");
What you are doing to echo uname element of an array is this:
Expand|Select|Wrap|Line Numbers
  1. echo $a[uname];
when you should be doing this:
Expand|Select|Wrap|Line Numbers
  1. echo $a['uname'];
You are also doing something like this:
Expand|Select|Wrap|Line Numbers
  1. echo $a['uname'] $a['sname'];
And that is exactly what that basic lesson is all about:
Expand|Select|Wrap|Line Numbers
  1. echo $a['uname']." ".$a['sname'];
Just apply this to your code and let us know how it went ;)
Dec 3 '11 #12
matheussousuke
249 100+
OK, I'll do it, but forgive my newbie lames if you find some. :P
Dec 3 '11 #13
omerbutt
638 512MB
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.  echo "<tr bgcolor=".$col."><td><a class=TN href=\"javascript:popUp('preview.php?uname=".$a1['uname']."&ename=$ename')\"> ".$a2[0].$a2[1]."</a>
  3.  </td><td>". $a1['clname']." </td></tr>";
  4.  
try this replace with you code
regards,
Omer Aslam
Dec 3 '11 #14
matheussousuke
249 100+
I tried but look at the code's color:

Dec 3 '11 #15
zorgi
431 Expert 256MB
Did you actually try to run that code. It looks like your editor is just highlighting strings in that colour.
Dec 3 '11 #16
matheussousuke
249 100+
of course, here:

Dec 3 '11 #17
matheussousuke
249 100+
As you can see, there is nothing between Nível and << Voltar field.
Dec 3 '11 #18
zorgi
431 Expert 256MB
Is there suppose to be? Can you set border on your table to 1 or inspect that part of your html with firebug so you can see what is echoed? Also do var_dump on all of your variables to see what they contain.
Dec 3 '11 #19
matheussousuke
249 100+
There should be results bellow "Nível", they are:
Name and Knowledge Level.

Can I use the Chrome Console?
Dec 3 '11 #20
matheussousuke
249 100+
Just as I expected, there is nothing below it, it like the php is not displaying the data:

The HTML part from the loaded page:
Expand|Select|Wrap|Line Numbers
  1. <table align="center" width="500" cellspacing="0">
  2.  
  3.     <caption align="center"><b> Candidatos para a vaga N° 1 / posição Pessoas com conhecimento em informática </b><br><font size="2"> Esta oferta foi visualizada 10 vezes e há 6 interessado(s). </font> </caption>
  4.  
  5.     <tbody><tr bgcolor="gray" style="font-family:arial; font-size:11; color:000000; font-weight:bold"><td width="150">Nome </td><td>Nível </td></tr></tbody></table>
Dec 3 '11 #21
zorgi
431 Expert 256MB
Giving me fragments of code like this doesn't help as error can be somewhere else. I absolutly can not see connection between your HTML and your php.
Dec 3 '11 #22
matheussousuke
249 100+
The full code:

Expand|Select|Wrap|Line Numbers
  1. <?
  2.  
  3. // Sistema de Empregos baseado no script Diesel Job Site versão 1.4
  4.  
  5.  
  6.  
  7. include_once "accesscontrol.php";
  8.  
  9. include_once "../configuration.inc.php";
  10.  
  11.  
  12.  
  13. $q1 = "select * from job_aplicants t1, job_careerlevel t2 where t1.aplicant = t2.uname and t1.job_id = \"$_GET[job_id]\" order by t2.clnumber desc";
  14.  
  15. $r1 = mysql_query($q1) or die(mysql_error());
  16.  
  17.  
  18.  
  19. //number of offer rerviews
  20.  
  21. $q22 = "select nv from job_post where job_id = \"$_GET[job_id]\" ";
  22.  
  23. $r22 = mysql_query($q22) or die(mysql_error());
  24.  
  25. $a22 = mysql_fetch_array($r22);
  26.  
  27.  
  28.  
  29. //number of offer aplicants
  30.  
  31. $q33 = "select count(aplicant) from job_aplicants where job_id = \"$_GET[job_id]\" ";
  32.  
  33. $r33 = mysql_query($q33) or die(mysql_error());
  34.  
  35. $a33 = mysql_fetch_array($r33);
  36.  
  37.  
  38.  
  39.  
  40.  
  41. echo "<br><br><br><table align=center width=500 cellspacing=0>
  42.  
  43.     <caption align=center><b> Candidatos para a vaga N° $_GET[job_id] / posição $position </b><br><font size=2> Esta oferta foi visualizada $a22[0] vezes e há $a33[0] interessado(s). </font> </caption>
  44.  
  45.     <tr bgcolor=gray style=\"font-family:arial; font-size:11; color:$s3white; font-weight:bold\"><td width=150>Nome </td><td>Nível </td></tr>";
  46.  
  47.  
  48.  
  49. $col = "cococo";
  50.  
  51.  
  52.  
  53. while ($a1 = mysql_fetch_array($r1))
  54.  
  55. {
  56.  
  57.     $q2 = "select fname, lname from job_seeker_info where uname = \"$a1[uname]\" ";
  58.  
  59.     $r2 = mysql_query($q2) or die(mysql_error());
  60.  
  61.     $a2 = mysql_fetch_array($r2);
  62.  
  63.  
  64.  
  65.      if($col == "cococo")
  66.  
  67.         { 
  68.  
  69.          $col = "dddddd"; 
  70.  
  71.         }
  72.  
  73.                   else
  74.  
  75.         { 
  76.  
  77.         $col = "cococo"; 
  78.  
  79.         } 
  80.  
  81. echo "<tr bgcolor=".$col."><td><a class=TN href=\"javascript:popUp('preview.php?uname=".$a1['uname']."&ename=$ename')\"> ".$a2[0].$a2[1]."</a>
  82.  </td><td>". $a1['clname']." </td></tr>";
  83. }
  84.  
  85. /*
  86.     echo "<tr bgcolor=\"$col\"><td><a class=TN href=\"javascript:popUp('preview.php?uname=$a1[uname]&ename=$ename')\"> $a2[0] $a2[1]</a></td><td> $a1[clname] </td></tr>";
  87. */
  88.  
  89. echo "</table><center><br><a class=TN href=employers7.php> << voltar</a></center>";
  90.  
  91.  
  92.  
  93. ?>
  94.  
  95. <? include_once('../footer.php'); ?>
Dec 3 '11 #23
zorgi
431 Expert 256MB
can you do var_dump($a1) on line 56
Dec 3 '11 #24
matheussousuke
249 100+
Parse error: syntax error, unexpected T_VARIABLE in /home/balcaoce/public_html/employers/employers15.php on line 57
Dec 3 '11 #25
zorgi
431 Expert 256MB
what is on lines 56,57,58
Dec 3 '11 #26
matheussousuke
249 100+
I have an idea, I sent you a copy of the file through PM.
Dec 3 '11 #27
zorgi
431 Expert 256MB
Did you do that var_dump?!
Dec 3 '11 #28
matheussousuke
249 100+
I did, I did it closing the tags, cause before I was receiving errors.

I inserted it in the line 56:

?><? var_dump($a1) ?><?

Got no error, but no results.
Dec 3 '11 #29
zorgi
431 Expert 256MB
First of all you forgot semicolon. Semicolon signifies the end of a PHP statement so you should get some error.

var_dump($a1);

Can you also do var_dump for $r1 on line 52.
Dec 3 '11 #30
matheussousuke
249 100+
Inserted the semicolon, still the same thing. And at line 52 I inserted ?><? var_dump($r1); ?><? and got this result:
resource(16) of type (mysql result)
Dec 3 '11 #31
zorgi
431 Expert 256MB
Ok it looks like your while loop is never executed becuse there is nothing to loop through. Check your SQL statement. Echo it out and check its well constructed. I would also use command line or phpMyAdmin to get results directly from database.

Also please go to this page: http://php.net/manual/en/language.types.array.php and read "Why is $foo[bar] wrong?"
Dec 3 '11 #32
matheussousuke
249 100+
So

Expand|Select|Wrap|Line Numbers
  1. echo "<tr bgcolor=".$col."><td><a class=TN href=\"javascript:popUp('preview.php?uname=".$a1['uname']."&ename=$ename')\"> ".$a2[0].$a2[1]."</a>
  2.  </td><td>". $a1['clname']." </td></tr>";
  3. }
is correct?
Dec 3 '11 #33
matheussousuke
249 100+
But that's so weird. This line
Expand|Select|Wrap|Line Numbers
  1. Esta oferta foi visualizada 10 vezes e há 6 interessado(s).
says the job has been viewed 10 times and that there is 6 interested people in it. if it says there is 6 interested people so that means somehow it is counting from real tables?
Dec 3 '11 #34
zorgi
431 Expert 256MB
about:
Expand|Select|Wrap|Line Numbers
  1. echo "<tr bgcolor=".$col."><td><a class=TN href=\"javascript:popUp('preview.php?uname=".$a1['uname']."&ename=$ename')\"> ".$a2[0].$a2[1]."</a>
  2.  </td><td>". $a1['clname']." </td></tr>";
Whay don't you check it? Simply create test.php and copy that code into it. Provide any values to the variables needed and run it.
Dec 3 '11 #35
matheussousuke
249 100+
I did a test, submitted my own job application, and it worked. :S
I dont know, maybe the system delete old applications.

By the way, now I'm having an attachment issue. I'll work around it, and if I have any problem, I go back and open another topic, but I dont think I'll have.
Dec 3 '11 #36
matheussousuke
249 100+
PS: Thank you very much for staying and helping me during 2 days. :D
Dec 3 '11 #37

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: uberderf | last post by:
I have the following web page setup: http://angels.uberderf.com/glossary.html I have a 2 column table layout which is a glossary of terms and their meanings. When you view this page in firefox...
3
by: Charles May | last post by:
I have a listview which checkboxes containing items to invoice. The Create Invoice button (button1) is disabled unless there are items checked. However, I had to use an if..then..else statement to...
4
by: Robert | last post by:
something wrong in wx I wrote program training na Artificial Neural Network. It work well in console mode, but when I try to add GUI there is an error: FANN Error 10: Error reading info from...
9
by: Eric Lilja | last post by:
Hello, I have two code snippets I want you to look at. My program compiles without warnings (warning level set to max, gcc 3.4.3) with either snippet but the latter one causes a segfault at...
3
by: Cor | last post by:
Hi all, I think I do something wrong, but I don't see what. I have made a sample. The sample needs only a form with a combobox and this code. (I can tell you that it took a long time to see...
1
by: Holly | last post by:
One of my clients called me this morning, having trouble with their blog loading. The blog does actually load, but only after such an unusually long wait it would have surely driven everyone else...
9
by: Randy | last post by:
Hi all, I've been working on a simple two column layout for a site, but according to browsershots.org, my desing is not showing up correctly in Win/IE 5.01, 5.5 & 6 ! Please see details here:...
1
by: alvarojaviervera | last post by:
Allways I think Firefox was strong, enough ... and so far THE BEST Web- browser (That what I Think) but, now Im fighting with it, may be Im doing something wrong (of course that is what happend to...
13
compman9902
by: compman9902 | last post by:
Hello, and thank you for hwlping me with this run-in with trouble. I am making a script for pig latin transulation, and there is something wrong with the "if" statement in line 51. Here is the code...
10
by: Guillermo_Lopez | last post by:
Hello All, I am using VBA in access to perform some calculations. There is a particular sumation that is wrong (barely). this code is withing a loop. TDist = TDist + TempDist Both TDist...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.