Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

PHP error when sending data to screen

Posted on 2014-08-26
9
Medium Priority
?
249 Views
Last Modified: 2014-08-26
I'd like to run a PHP script to return the values in a database, I can do it with no problem but when I add the "Order by" into my script, I am getting an error.  This script worked great until I added the "order by".
Here is my simple script...Please advise:  
----------------------------------------------------------------------------------------------------------
Here is when I connect to MYSQL (Left that part out)
---------------------------------------------------------------------------------------------------------

$result = mysqli_query($con,"SELECT ItemNumber, StartingDate, EndingDate, SalePrice FROM biomas.ITProductSale order by ItemNumber");

 echo "<table border='1'>
 <tr>
 <th>Item Number</th>
 <th>Starting Date</th>
 <th>Ending Date</th>
 <th>Sale Price</th>
 </tr>";

 while($row = mysqli_fetch_array($result))
   {I
   echo "<tr>";
   echo "<td>" . $row['ItemNumber'] . "</td>";
   echo "<td>" . $row['StartingDate'] . "</td>";
   echo "<td>" . $row['EndingDate'] . "</td>";
   echo "<td>" . $row['SalePrice'] . "</th>";
   echo "</tr>";
   }
 echo "</table>";

 mysqli_close($con);
 ?>
------------------------------------------------------------------------------
0
Comment
Question by:Scott Johnston
9 Comments
 
LVL 36

Expert Comment

by:gr8gonzo
ID: 40286667
What is the error you're getting?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40286669
What is biomas
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40286670
I have never seen that cause a problem.  What is the error message?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Scott Johnston
ID: 40286678
Has to do with the line "echo "<tr>";"
Parse Error: syntax Error, unexpected T_ECHO in (FIle name)C:\Inetpub\xxxxxxxxxx\xxxxxxxxxxxxxxxx on line 21"

I do not see my error, or because I am sorting the data it will not print out the same...?
0
 

Author Comment

by:Scott Johnston
ID: 40286679
BIOMAS name of our MYSQL database
0
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 40286683
Is that an exact copy of your code?

while($row = mysqli_fetch_array($result))
   {I // what is the l doing here?
    echo "<tr>";


Also
echo "<td>" . $row['SalePrice'] . "</th>";
You are opening a TD tag and closing a TH tag - no biggie but should be corrected.
0
 

Author Comment

by:Scott Johnston
ID: 40286686
I put the Select statement in MYSQL and it works perfectly....
0
 

Author Comment

by:Scott Johnston
ID: 40286690
Hmmm, missed that...Fixed everything>!!!!!!
0
 

Author Closing Comment

by:Scott Johnston
ID: 40286691
Sometime it help to have more than one person looking at coding even as simple as this code...Thanks
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

578 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