Solved

SQL Error

Posted on 2009-07-15
10
185 Views
Last Modified: 2012-05-07
I'm trying to add a line to the coding below. The one I am having issues with is commented out, put it is causing a white page to occur. I know it's a simple syntex error that I'm over looking.
The line above, and below work fine, so I copied one of them and simply changed the information it was calling. Please help!!
<?php
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); 
mysql_select_db($db) or die ("Unable to select database!"); 
$query = "SELECT * 
FROM `voc2_gift` 
LIMIT 0 , 30 "; 
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 
if (mysql_num_rows($result) > 0) { 
echo "<table bgcolor=#000000 cellpadding=50 width=100 border=1 bordercolorlight=#00FF00 bordercolorlight=#00FF00 bordercolordark=#00FF00>";
 
  $numItems = mysql_numrows($result);
  $itemsPerRow = 4;
  $itemsCounter = 0;
 
  for($i=0;$i<$numItems;$i++) {
    if($itemsCounter==0) { echo "<tr>"; }
    echo "<td><center><img src='".mysql_result($result,$i,"GiftURL")."'>";
echo "<input type=button value='Send' onclick='sendImage(".mysql_result($result,$i,"GiftURL").")'>";
    // echo "<p>".mysql_result($result,$i,"GiftPrice").;
    echo "<p>".mysql_result($result,$i,"GiftName")."</center></td>"; 
 
    if($itemsCounter==3) { echo "</tr>"; }
    $itemsCounter = ($itemsCounter+1)%$itemsPerRow;
  }
 
  echo "</table>"; 
 
} else { 
  echo "No rows found!"; 
} 
?>

Open in new window

0
Comment
Question by:mimoser
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 3
10 Comments
 
LVL 4

Accepted Solution

by:
Xemorph earned 500 total points
ID: 24865192
You have a '.' at the end of your statement, that will cause a parse error
0
 
LVL 14

Expert Comment

by:flob9
ID: 24865207
Please, show us the fields of the table voc2_gift.
0
 

Author Comment

by:mimoser
ID: 24865216
I left the period in the line, because the line below also has a period at the begining and end, which works.

Those table fields are

GiftID
GiftName
GiftURL
GiftPrice
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:Xemorph
ID: 24865254
I would try to check your PHP logs.  That will tell you if there was a fatal error that occurred, and what it was.
0
 
LVL 14

Expert Comment

by:flob9
ID: 24865275
Add this before the mysql_connect :

error_reporting(E_ALL);

then, uncomment the line

echo "<p>".mysql_result($result,$i,"GiftPrice");

and tell us what happen.
0
 

Author Comment

by:mimoser
ID: 24865324
[15-Jul-2009 18:59:13] PHP Parse error:  syntax error, unexpected ';' in public_html/gift.php on line 118

0
 
LVL 14

Expert Comment

by:flob9
ID: 24865379
remove the dot before ";" :)
0
 
LVL 4

Expert Comment

by:Xemorph
ID: 24865382
If line 118 is line 19 in your posted code, I believe it is the '.' like I said before.  If the code changed at all, post what was ran.

Thanks.
0
 

Author Closing Comment

by:mimoser
ID: 31604046
That worked. Thank you, it had me confused because of the . in front of
.mysql_result
so I thought one was needed at the end as well.
0
 
LVL 14

Expert Comment

by:flob9
ID: 24865510
nice one :)
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Export individual report to pdf 2 41
Reoccurring Access Query 24 47
Prestashop modules custimzation 2 27
PHP, Curl and XML 13 15
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question