Jump to content

Connect to MySQL and display data not working


fwapah

Recommended Posts

The account I created yesterday is not valid for some reason, so I created this new one.

 

I cannot get this code to work in my browser to save my life, though it looks good in Dreamweaver (not written in DW though). Can someone please tell me why it won't display? I'm afraid it has something to do with my server, which is very limiting.

 

Thanks so much for your help.

 

the tables are grant and reviewer. Fields are

 

REVIEWER

rid (primary, unique)

rfirst

rlast

rpass

grant1

grant2

 

GRANT

gnum

gfirst

glast

rid

gscore1

gscore2

gcomm1

gcomm2

Here is the code another phpfreak helped me write, but I have messed with it:

<html><?php
  $rid = $_GET["rid"];


mysql_connect("xxx.com", "xxx", "xxx") or die(mysql_error());
mysql_select_db("nsac") or die(mysql_error());

$query="SELECT * FROM grants
JOIN reviewers as r1 ON grants.reviewer1id = r1.id
JOIN reviewers as r2 ON grants.reviewer2id = r2.id
WHERE r1.reviewer1id = '".$_GET['rid']."' OR r2.reviewer2id = '".$_GET['rid']."'";
$rt=mysql_query($query); 
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td colspan="4">Grants for your review</td>
</tr>

<tr>
<td align="center"><strong>First</strong></td>
<td align="center"><strong>Last</strong></td>
<td align="center"><strong>Grant #</strong></td>
<td align="center"><strong>Update</strong></td>
</tr>
<tr>
<td><? echo $rt['gfirst']; ?></td>
<td><? echo $rt['glast']; ?></td>
<td><? echo $rt['gnum']; ?></td>
<td align="center"><a href="update.php?id=<? echo $rt['gnum']; ?>">update</a></td>
</tr>
</table>
</td>
</tr>
</table>
<?php
mysql_close();
?>

</html>

 

 

Thanks again!!

Link to comment
Share on other sites

Thanks for the error reporting tip.. duh! can't believe i forgot that.. but here's what i get:

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'grant JOIN reviewers as r1 ON grant.reviewer1id = r1.id JOIN reviewers as r2 O' at line 1

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.