Jump to content

Recommended Posts

This doesn't work inside html.

<tr valign="top">
                <td height="22" align="right" valign="middle"><!-- <img src="images/bult-gamblingtemplatesdotnet.jpg" width="11" height="11"> --></td>
                <td height="22" valign="middle"><class="navbar3">
                <?php
		include("config.php");
		$result = mysql_query("SELECT name, lic_num, purpose FROM charity where sysdate() between start_date and end_date");
		while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
		print "<b>Charity: </b>".$row{'name'}."<br><b>License #: </b>".$row{'lic_num'}."<br><b>Purpose: </b>".$row{'purpose'}."<p>";
		}
		mysql_close($dbh);
	?></td>

 

This is the output on the website.

Charity: ".$row{'name'}."
License #: ".$row{'lic_num'}."
Purpose: ".$row{'purpose'}."

"; } mysql_close($dbh); ?>

 

When I do this

<tr valign="top">
     <td height="22" align="right" valign="middle"><!-- <img src="images/bult-gamblingtemplatesdotnet.jpg" width="11" height="11"> --></td>
     <td height="22" valign="middle"><class="navbar3"><?php include("test.php"); ?></td>
</tr>

 

I get this



 

Can someone please point me in the correct direction?

Also if I run the code as a stand alone it works perfectly.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/235120-php-code-in-html/
Share on other sites

It's in a .php file and I'm using include

Here is the test.php file;

<?php
include("config.php");
$result = mysql_query("SELECT name, lic_num, purpose FROM charity where sysdate() between start_date and end_date");
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
print "<b>Charity: </b>".$row{'name'}."<br><b>License #: </b>".$row{'lic_num'}."<br><b>Purpose: </b>".$row{'purpose'}."<p>";
}
mysql_close($dbh);
?>

 

Where config.php is the database connect info.

 

Link to comment
https://forums.phpfreaks.com/topic/235120-php-code-in-html/#findComment-1208357
Share on other sites

I'm thinking that the query is returning an empty result set. Do you get any results returned if you paste the query "SELECT name, lic_num, purpose FROM charity where sysdate() between start_date and end_date" in to phpMyAdmin (or whatever you prefer to use) and execute it?

 

From looking at it, it seems like it should read more like:

SELECT name, lic_num, purpose FROM charity where start_date < NOW() AND end_date > NOW()

Link to comment
https://forums.phpfreaks.com/topic/235120-php-code-in-html/#findComment-1208375
Share on other sites

In my HTML code I am using it like this:

<tr valign="top">
     <td height="22" align="right" valign="middle"><!-- <img src="images/bult-gamblingtemplatesdotnet.jpg" width="11" height="11"> --></td>
     <td height="22" valign="middle"><class="navbar3"><?php include("test.php"); ?></td>
</tr>

 

Here is the webiste as it sits using the above: http://dswdesigns.net/pp4c/index.html

Here is the stand alone code of test.php and it works: http://dswdesigns.net/pp4c/test.php

 

Thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/235120-php-code-in-html/#findComment-1208388
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.