Jump to content

[SOLVED] Help displaying information from a database.


The.Pr0fess0r

Recommended Posts

Hello, I am still very new to PHP, and am not sure on how to retrieve the data I am looking for.

 

OK here is my situation. I have a table with three columns (id, date, content). In this table I am using a form to insert small news articles.

 

On one side of my site I have a small area to post these articles. I only want to post the two most recent articles though and I am not sure how to do that?

 

I would like the site to show the date and then on the next line, the content of the news.

 

I'm pretty sure that I am going to have to user a while statement where the counter has to be less than or equal to 2. Then after the first article add one to the counter.

 

I'm just not sure how to code that.

 

I have tried searching the web and this site, I'm just not sure what to search for so I haven't found anything real useful.

 

Any help would be greatly appreciated.

Link to comment
Share on other sites


$query = "select id, date, content from <table name> order by date desc limit 2";

$result = mysql_query($query);


while( $rows = mysql_fetch_assoc($result) ) {
  echo $row['date'] . '<br />';
  echo '<div style="padding: 10px">' . $row['content'] . '</div>;
}

Link to comment
Share on other sites

Okay this is a MYSQL and PHP question

 

Here a basic script to start with


<?php
//Database host / ssername /password 
$conn = mysql_connect("localhost", "mysql_user", "mysql_password");

//check connection
if (!$conn) {
    echo "Unable to connect to DB: " . mysql_error();
    exit;
}

//database name 
if (!mysql_select_db("mydbname")) {
    echo "Unable to select mydbname: " . mysql_error();
    exit;
}

//SQL Query
$sql = "$sql = "SELECT * FROM sometable  WHERE  userstatus = 1 LIMIT 5";";

$result = mysql_query($sql);

if (!$result) {
    echo "Could not successfully run query ($sql) from DB: " . mysql_error();
    exit;
}

if (mysql_num_rows($result) == 0) {
    echo "No rows found, nothing to print so am exiting";
    exit;
}

// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
//       then create $userid, $fullname, and $userstatus
while ($row = mysql_fetch_assoc($result)) {
    echo $row["userid"];
    echo $row["fullname"];
    echo $row["userstatus"];
}

mysql_free_result($result);

?>

 

 

Take note of the

1.

$sql = "SELECT * FROM sometable  WHERE  userstatus = 1 LIMIT 5";

and

 

2.

while ($row = mysql_fetch_assoc($result)) {
    echo $row["userid"];
    echo $row["fullname"];
    echo $row["userstatus"];
}

 

Now

1. finds every field in sometable WHERE the field userstatus  = 1 and only finds up to 5 results

2. fetches that data and puts it into $row and continues until no more records are found (as the QUERY only finds up to 5 it will only loop a maximum of 5 times

and it echos the fields userid, fullname and userstatus

 

Play with that and see what you get and if yo get stuck just post back

 

 

Link to comment
Share on other sites

Ok, thank you for the code MadTechie. I inserted that code into my page where I would like the data to appear, but nothing happens. My page still loads, but nothing shows up in the area of that page.

 

I don't receive any errors, it's just that nothing shows up.

 

Here is the code that I entered:

<?php
//Database host / ssername /password 
$conn = mysql_connect("localhost", "myusername", "mypassword);

//check connection
if (!$conn) {
    echo "Unable to connect to DB: " . mysql_error();
    exit;
}

//database name 
if (!mysql_select_db("database_database")) {
    echo "Unable to select database: " . mysql_error();
    exit;
}

//SQL Query
$sql = "$sql = "SELECT * FROM recent_news  WHERE  status = 1 LIMIT 2";

$result = mysql_query($sql);

if (!$result) {
    echo "Could not successfully run query ($sql) from DB: " . mysql_error();
    exit;
}

if (mysql_num_rows($result) == 0) {
    echo "No rows found, nothing to print so am exiting";
    exit;
}

// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
//       then create $userid, $fullname, and $userstatus
while ($row = mysql_fetch_assoc($result)) {
    echo $row["date"];<br>
    echo $row["content"];<br><br>
}

mysql_free_result($result);

?>

 

I changed the username, password, and database name for obvious security reasons.

 

I'm lost here. I would have thought that I should see an error if it was not connecting to the database properly. But i'm not seeing any errors.

 

Any help will be greatly appreciated!

 

Here is the code for the entire page:


<HTML>

<HEAD>

<TITLE>My Fish and Game Tracker</TITLE>

<META http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link href="custom.css" rel="stylesheet" type="text/css">

</HEAD>

<BODY>

<TABLE width="762" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
<TR>
	<TD colspan="5" align="right"> <a style="font-size:x-small;" href="http://www.mywebsite.com/main.php">Login</a></TD>
</TR>
<TR>

	<TD colspan="3" id="logofield"></TD>

	<TD width="231">

		<IMG src="images/topimg1.jpg" width="231" height="128" alt=""></TD>

	<TD colspan="2">

		<IMG src="images/topimg2.jpg" alt="" width="191" height="128" border="0" usemap="#toplinks"></TD>

</TR>

<TR>

	<TD colspan="6">

		<IMG src="images/topbar.gif" width="762" height="10" alt=""></TD>

</TR>

<TR>

	<TD id="leftcol" colspan="2" valign="top">

	<table width="100%"  border="0" cellpadding="0" cellspacing="0">

          <tr>

            <td width="9" class="lnmenuleft"> </td>

             <td width="143" id="menu"><p> <a href="index.html">Home</a><br>

              <a href="events.html">Events</a><br>

              <a href="team.html">Team</a><br>

              <a href="gallery.html"> Gallery</a><br>

              <a href="members.html"> Members </a><br>

              <a href="about_us.html">About us</a><br>
		  
              <a href="contact_us.html">Contact us</a></p>

            </td>

          </tr>

          <tr>

            <td height="10" colspan="2"><img src="images/menu-bottom.gif" alt="" width="152" height="10"></td>

          </tr>

        </table></TD>

      <TD colspan="3" rowspan="2" valign="top" bgcolor="#FFFFFF"><table width="603" border="0" cellpadding="0" cellspacing="0">

        <tr>

          <td width="419" rowspan="4" valign="bottom" id="maincontent"><h1>Welcome to My Fish and Game Tracker!</h1>

            <p><span class="promo">Thank you for visiting my website</span></p>

            <p>If you would like to contribute to the site with your reports please send an email to <a href="mailto:loginrequest@myfishandgametracker.com?subject=Login%20Requested">loginrequest@myfishandgametracker.com</a>. Please include your name and the login id you would like to use. <br>

                <br>

  New updates will be added frequently to the site, so please check back often!</p>

            <table id="promo" width="375" border="0" align="center" cellpadding="0" cellspacing="0">

            <tr>

              <td><h1>Update 08/07/09</h1>

                <br>

                <span class="promo">

                <u>Features Added:</u> <BR>

- Fish Trip Entry Form Added<br>
- Fish Information Form Added </span></td>

            </tr>

          </table></td>
		<td width="184" class="article_content" id="newsbox">            <h1>LATEST NEWS</h1>

<br>
<?php
//Database host / username /password 
$conn = mysql_connect("localhost", "myusername", "mypassword");

//check connection
if (!$conn) {
    echo "Unable to connect to DB: " . mysql_error();
    exit;
}

//database name 
if (!mysql_select_db("mydatabase")) {
    echo "Unable to select database: " . mysql_error();
    exit;
}

//SQL Query
$sql = "$sql = "SELECT * FROM recent_news  WHERE  status = 1 LIMIT 2";

$result = mysql_query($sql);

if (!$result) {
    echo "Could not successfully run query ($sql) from DB: " . mysql_error();
    exit;
}

if (mysql_num_rows($result) == 0) {
    echo "No rows found, nothing to print so am exiting";
    exit;
}

// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
//       then create $userid, $fullname, and $userstatus
while ($row = mysql_fetch_assoc($result)) {
    echo $row["date"];<br>
    echo $row["content"];<br><br>
}

mysql_free_result($result);

?>

          </td>

        </tr>

        <tr>

          <td height="8" valign="top"><img src="images/blueline.gif" alt="" width="184" height="8"></td>

        </tr>

        <tr>

          <td height="132" valign="top"><img src="images/photo.jpg" alt="" width="184" height="132"></td>

        </tr>

        <tr>

          <td height="21"> </td>

        </tr>

      </table>			  </TD>

  <TD width="8" rowspan="4"> </TD>

</TR>

<TR>

	<TD width="9" rowspan="3"> </TD>

	<TD width="143" height="68" valign="top" class="contact"><br><p><br>

<br>

<br>

<br>

<a href="mailto:admin@mywebsite.com?subject=Website%20Help">Email Admin</a></p>

    </TD>

</TR>

<TR>

	<TD colspan="4" valign="top">

		<IMG src="images/blueline.gif" width="746" height="8" alt=""></TD>

</TR>

<TR>

	<TD width="143">

		<IMG src="images/footer-left.gif" width="143" height="36" alt=""></TD>

	<TD colspan="2" class="footer"></TD>

	<TD width="200">

		<IMG src="images/footer-right.gif" width="184" height="36" alt=""></TD>

</TR>

<TR>

	<TD width="9">

		<IMG src="images/spacer.gif" width="9" height="1" alt=""></TD>

	<TD width="143">

		<IMG src="images/spacer.gif" width="143" height="1" alt=""></TD>

	<TD width="188">

		<IMG src="images/spacer.gif" width="188" height="1" alt=""></TD>

	<TD width="231">

		<IMG src="images/spacer.gif" width="231" height="1" alt=""></TD>

	<TD width="200">

		<IMG src="images/spacer.gif" width="184" height="1" alt=""></TD>

	<TD width="8">

		<IMG src="images/spacer.gif" width="7" height="1" alt=""></TD>

</TR>

</TABLE>

<map name="toplinks">

  <area shape="rect" coords="18,110,39,131" href="index.html" alt="">

  <area shape="rect" coords="55,109,83,130" href="contact_us.html" alt="">

  <area shape="rect" coords="96,109,122,127" href="about_us.html" alt="">

</map>

</BODY>

</HTML>

Link to comment
Share on other sites

not sure if this is the cause of your problem , or a simple copy paste error, but there is a syntax error in the 2nd or 3rd line in your code

 

<?php
//Database host / ssername /password 
$conn = mysql_connect("localhost", "myusername", "mypassword);

should be

 

<?php
//Database host / ssername /password 
$conn = mysql_connect("localhost", "myusername", "mypassword");//<-missing a quotation mark

Link to comment
Share on other sites

If mikesta's suggestion isn't the solution,which it doesn't look like it will be because you have the quote in your second code block, then it sounds like there is a fatal error, usually syntactical.  Try turning error_reporting on.  Place these lines directly after your opening PHP tags.

 

ini_set ("display_errors", "1");
error_reporting(E_ALL);

Link to comment
Share on other sites

OK, when I place that code just after my opening PHP tags I get the following message:

 

Fatal error: Call to undefined function phpini_set() in /home/me/public_html/mysite.com/index.php on line 1

 

I'm not sure why it would say line 1 though. The php code is down on lines 116-160?

 

Looks like you're not separating the opening <?php tag and the ini_set() function.

 

You also have an error here (Also, if you didn't fix what mikesta suggest, do so):

 

$sql = "$sql = "SELECT * FROM recent_news  WHERE  status = 1 LIMIT 2";

 

Should be:

 

$sql = "SELECT * FROM recent_news  WHERE  status = 1 LIMIT 2";

Link to comment
Share on other sites

and of course, update the loop to

while ($row = mysql_fetch_assoc($result)) {
    echo $row["date"]."<br>";
    echo $row["content"]."<br><br>";
}

 

also check your data, manually run the query

SELECT * FROM recent_news  WHERE  status = 1 LIMIT 2

to check you have data

Link to comment
Share on other sites

OK, so I made the change in the loop and also fixed the spacing after my php tags. Now, I am back to where I was before. Just a blank area shows up. I'm not receiving any errors, but the "news section of my site" is not showing up with any information either.

 

Just for the heck of it I changed my username so it was incorrect in the following line:

 

$conn = mysql_connect("localhost", "myusername", "mypassword");

 

But when I looked at my page I am not receiving any errors...just a blank area where the results of my query should show up.

 

According to the next lines of code:

//check connection
if (!$conn) {
    echo "Unable to connect to DB: " . mysql_error();
    exit;
}

 

I should be receiving an error message if it couldn't connect, shouldn't I?

 

 

 

Link to comment
Share on other sites

try adding the following debug code

//DEBUG
$row = mysql_fetch_assoc($result);
var_dump($row);
die;
//END DEBUG
//Below is existing code
while ($row = mysql_fetch_assoc($result)) {
    echo $row["date"]."<br>";
    echo $row["content"]."<br><br>";
}

it it doesn't appear view source and check the last few lines for any errors

Link to comment
Share on other sites

OK, it looks to be something else in my code besides the statements we have been working on. I took the code that MadTechie originally suggested and put it into a basic table. Saved the doc as testing.php uploaded it to my file server and it worked perfectly.

 

So, there must be something in the other code on the page that is causing this query not to pull properly.

 

Here is my index page exactly as it stands now. (username, password, and db name edited)

<HTML>

<HEAD>

<TITLE>My Fish and Game Tracker</TITLE>

<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> 

<link href="custom.css" rel="stylesheet" type="text/css">

</HEAD>

<BODY>

<TABLE width="762" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
<TR>
	<TD colspan="5" align="right"> <a style="font-size:x-small;" href="http://www.mysite.com/main.php">Login</a></TD>
</TR>
<TR>

	<TD colspan="3" id="logofield"></TD>

	<TD width="231">

		<IMG src="images/topimg1.jpg" width="231" height="128" alt=""></TD>

	<TD colspan="2">

		<IMG src="images/topimg2.jpg" alt="" width="191" height="128" border="0" usemap="#toplinks"></TD>

</TR>

<TR>

	<TD colspan="6">

		<IMG src="images/topbar.gif" width="762" height="10" alt=""></TD>

</TR>

<TR>

	<TD id="leftcol" colspan="2" valign="top">

	<table width="100%"  border="0" cellpadding="0" cellspacing="0">

          <tr>

            <td width="9" class="lnmenuleft"> </td>

             <td width="143" id="menu"><p> <a href="index.html">Home</a><br>

              <a href="events.html">Events</a><br>

              <a href="team.html">Team</a><br>

              <a href="gallery.html"> Gallery</a><br>

              <a href="members.html"> Members </a><br>

              <a href="about_us.html">About us</a><br>
		  
              <a href="contact_us.html">Contact us</a></p>

            </td>

          </tr>

          <tr>

            <td height="10" colspan="2"><img src="images/menu-bottom.gif" alt="" width="152" height="10"></td>

          </tr>

        </table></TD>

      <TD colspan="3" rowspan="2" valign="top" bgcolor="#FFFFFF"><table width="603" border="0" cellpadding="0" cellspacing="0">

        <tr>

          <td width="419" rowspan="4" valign="bottom" id="maincontent"><h1>Welcome to My Fish and Game Tracker!</h1>

            <p><span class="promo">Thank you for visiting My Fish and Game Tracker! This site was created for hunting and fishing enthusiasts alike to keep track of their outdoor adventures.</span></p>

            <p>If you would like to contribute to the site with your reports please send an email to <a href="mailto:loginrequest@mysite.com?subject=Login%20Requested">loginrequest@mysite.com</a>. Please include your name and the login id you would like to use. <br>

                <br>

  New updates will be added frequently to the site, so please check back often!</p>

            <table id="promo" width="375" border="0" align="center" cellpadding="0" cellspacing="0">

            <tr>

              <td><h1>Update 08/07/09</h1>

                <br>

                <span class="promo">

                <u>Features Added:</u> <BR>

- Fish Trip Entry Form Added<br>
- Fish Information Form Added </span></td>

            </tr>

          </table></td>
		<td width="184" class="article_content" id="newsbox"> 
			<table>
				<tr>
					<td><h1>LATEST NEWS</h1>

<br>
<?php ini_set ("display_errors", "1");
error_reporting(E_ALL);

//Database host / username /password 
$conn = mysql_connect("localhost", "*********", "*********");

//check connection
if (!$conn) {
    echo "Unable to connect to DB: " . mysql_error();
    exit;
}

//database name 
if (!mysql_select_db("*******_*****")) {
    echo "Unable to select databasename: " . mysql_error();
    exit;
}

//SQL Query
$sql = "SELECT * FROM recent_news  WHERE  status = 1 LIMIT 2";

$result = mysql_query($sql);

if (!$result) {
    echo "Could not successfully run query ($sql) from DB: " . mysql_error();
    exit;
}

if (mysql_num_rows($result) == 0) {
    echo "No rows found, nothing to print so am exiting";
    exit;
}
//DEBUG
$row = mysql_fetch_assoc($result);
var_dump($row);
die;
//END DEBUG
//Below is existing code
// While a row of data exists, put that row in $row as an associative array
// Note: If you're expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you'll
//       then create $userid, $fullname, and $userstatus
while ($row = mysql_fetch_assoc($result)) {
    echo $row["date"]."<br>";
    echo $row["content"]."<br><br>";
}

mysql_free_result($result);

?>
					</td>
				</tr>
			</table>	

          </td>

        </tr>

        <tr>

          <td height="8" valign="top"><img src="images/blueline.gif" alt="" width="184" height="8"></td>

        </tr>

        <tr>

          <td height="132" valign="top"><img src="images/photo.jpg" alt="" width="184" height="132"></td>

        </tr>

        <tr>

          <td height="21"> </td>

        </tr>

      </table>			  </TD>

  <TD width="8" rowspan="4"> </TD>

</TR>

<TR>

	<TD width="9" rowspan="3"> </TD>

	<TD width="143" height="68" valign="top" class="contact"><br><p><br>

<br>

<br>

<br>

<a href="mailto:admin@mysite.com?subject=Website%20Help">Email Admin</a></p>

    </TD>

</TR>

<TR>

	<TD colspan="4" valign="top">

		<IMG src="images/blueline.gif" width="746" height="8" alt=""></TD>

</TR>

<TR>

	<TD width="143">

		<IMG src="images/footer-left.gif" width="143" height="36" alt=""></TD>

	<TD colspan="2" class="footer"></TD>

	<TD width="200">

		<IMG src="images/footer-right.gif" width="184" height="36" alt=""></TD>

</TR>

<TR>

	<TD width="9">

		<IMG src="images/spacer.gif" width="9" height="1" alt=""></TD>

	<TD width="143">

		<IMG src="images/spacer.gif" width="143" height="1" alt=""></TD>

	<TD width="188">

		<IMG src="images/spacer.gif" width="188" height="1" alt=""></TD>

	<TD width="231">

		<IMG src="images/spacer.gif" width="231" height="1" alt=""></TD>

	<TD width="200">

		<IMG src="images/spacer.gif" width="184" height="1" alt=""></TD>

	<TD width="8">

		<IMG src="images/spacer.gif" width="7" height="1" alt=""></TD>

</TR>

</TABLE>

<map name="toplinks">

  <area shape="rect" coords="18,110,39,131" href="index.html" alt="">

  <area shape="rect" coords="55,109,83,130" href="contact_us.html" alt="">

  <area shape="rect" coords="96,109,122,127" href="about_us.html" alt="">

</map>

</BODY>

</HTML>

 

Any help finding the culprit will be greatly appreciated!

 

Link to comment
Share on other sites

When I added the var_dump() and viewed the source, I didn't notice anything different. Here is the source for my index page after adding the debug commands.

 

<HTML><HEAD><TITLE>My Fish and Game Tracker</TITLE><!-- Designed by SOHOtemplates.com--><META http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link href="custom.css" rel="stylesheet" type="text/css"></HEAD><BODY><TABLE width="762" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">	<TR>		<TD colspan="5" align="right"> <a style="font-size:x-small;" href="http://www.myfishandgametracker.com/main.php">Login</a></TD>	</TR>	<TR>		<TD colspan="3" id="logofield"></TD>		<TD width="231">			<IMG src="images/topimg1.jpg" width="231" height="128" alt=""></TD>		<TD colspan="2">			<IMG src="images/topimg2.jpg" alt="" width="191" height="128" border="0" usemap="#toplinks"></TD>	</TR>	<TR>		<TD colspan="6">			<IMG src="images/topbar.gif" width="762" height="10" alt=""></TD>	</TR>	<TR>		<TD id="leftcol" colspan="2" valign="top">				<table width="100%"  border="0" cellpadding="0" cellspacing="0">          <tr>            <td width="9" class="lnmenuleft"> </td>             <td width="143" id="menu"><p> <a href="index.html">Home</a><br>              <a href="events.html">Events</a><br>              <a href="team.html">Team</a><br>              <a href="gallery.html"> Gallery</a><br>              <a href="members.html"> Members </a><br>              <a href="about_us.html">About us</a><br>			                <a href="contact_us.html">Contact us</a></p>            </td>          </tr>          <tr>            <td height="10" colspan="2"><img src="images/menu-bottom.gif" alt="" width="152" height="10"></td>          </tr>        </table></TD>      <TD colspan="3" rowspan="2" valign="top" bgcolor="#FFFFFF"><table width="603" border="0" cellpadding="0" cellspacing="0">        <tr>          <td width="419" rowspan="4" valign="bottom" id="maincontent"><h1>Welcome to My Fish and Game Tracker!</h1>            <p><span class="promo">Thank you for visiting My Fish and Game Tracker! This site was created for hunting and fishing enthusiasts alike to keep track of their outdoor adventures.</span></p>            <p>If you would like to contribute to the site with your reports please send an email to <a href="mailto:loginrequest@myfishandgametracker.com?subject=Login%20Requested">loginrequest@myfishandgametracker.com</a>. Please include your name and the login id you would like to use. <br>                <br>  New updates will be added frequently to the site, so please check back often!</p>            <table id="promo" width="375" border="0" align="center" cellpadding="0" cellspacing="0">            <tr>              <td><h1>Update 08/07/09</h1>                <br>                <span class="promo">                <u>Features Added:</u> <BR> - Fish Trip Entry Form Added<br> - Fish Information Form Added </span></td>            </tr>          </table></td>			<td width="184" class="article_content" id="newsbox"> 				<table>					<tr>						<td><h1>LATEST NEWS</h1><br><p></p>						</td>					</tr>				</table>	          </td>        </tr>        <tr>          <td height="8" valign="top"><img src="images/blueline.gif" alt="" width="184" height="8"></td>        </tr>        <tr>          <td height="132" valign="top"><img src="images/photo.jpg" alt="" width="184" height="132"></td>        </tr>        <tr>          <td height="21"> </td>        </tr>      </table>			  </TD>	  <TD width="8" rowspan="4"> </TD>	</TR>	<TR>		<TD width="9" rowspan="3"> </TD>		<TD width="143" height="68" valign="top" class="contact"><br><p><br><br><br><br><a href="mailto:admin@myfishandgametracker.com?subject=Website%20Help">Email Admin</a></p>	    </TD>	</TR>	<TR>		<TD colspan="4" valign="top">			<IMG src="images/blueline.gif" width="746" height="8" alt=""></TD>	</TR>	<TR>		<TD width="143">			<IMG src="images/footer-left.gif" width="143" height="36" alt=""></TD>		<TD colspan="2" class="footer"></TD>		<TD width="200">			<IMG src="images/footer-right.gif" width="184" height="36" alt=""></TD>	</TR>	<TR>		<TD width="9">			<IMG src="images/spacer.gif" width="9" height="1" alt=""></TD>		<TD width="143">			<IMG src="images/spacer.gif" width="143" height="1" alt=""></TD>		<TD width="188">			<IMG src="images/spacer.gif" width="188" height="1" alt=""></TD>		<TD width="231">			<IMG src="images/spacer.gif" width="231" height="1" alt=""></TD>		<TD width="200">			<IMG src="images/spacer.gif" width="184" height="1" alt=""></TD>		<TD width="8">			<IMG src="images/spacer.gif" width="7" height="1" alt=""></TD>	</TR></TABLE><map name="toplinks">  <area shape="rect" coords="18,110,39,131" href="index.html" alt="">  <area shape="rect" coords="55,109,83,130" href="contact_us.html" alt="">  <area shape="rect" coords="96,109,122,127" href="about_us.html" alt=""></map></BODY></HTML>

 

In the source code above, right after Latest News is where the PHP code is inserted.

Link to comment
Share on other sites

OK, I apologize for wasting everyone's time. It's working now...but I have no idea why. All I did was copy the code row by row into a new page. My goal here was to find out what part of the code was not working. In the end I copied and pasted the entire (old) index.php file into a new file called testing.php, uploaded it and it worked!

 

Not sure why but I renamed the testing.php to index.php, uploaded it to my web server and everything started working properly!

 

Thank you all so much for your help. Even though I don't know what was wrong with my code I learned a lot about php that will help me out greatly in the future!

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.