image counter

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Nanaosei
Forum Newbie
Posts: 9
Joined: Sat Sep 22, 2007 7:01 pm

image counter

Post by Nanaosei »

I have created an image counter in php extension page I will like to give this counter to friends who would like to copy and paste the counter into their html extension pages. I have tried using javascript to search for my php file but on their pages nothing prints out.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Are you asking a question, or simply making an odd introduction of yourself?
Nanaosei
Forum Newbie
Posts: 9
Joined: Sat Sep 22, 2007 7:01 pm

image counter

Post by Nanaosei »

I really need help and I am asking a question
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Your question is likely impossible to answer without making lots of assumptions. Rather than have us make said assumptions, please post your code, what you've tried to fix it, and how you want it to work. We'll be able to suggest things from there.
Nanaosei
Forum Newbie
Posts: 9
Joined: Sat Sep 22, 2007 7:01 pm

Post by Nanaosei »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


This is my php files

Code: Select all

<?php // db.php
//session_start();
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'admin';

function dbConnect($db='') {
    global $dbhost, $dbuser, $dbpass;
    
    $dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
        or die('The site database appears to be down.');

    if ($db!='' and !@mysql_select_db($db))
        die('The site database is unavailable.');
    
    return $dbcnx;
}
?>
<?php 
include 'db.php';
?>

<?php
dbConnect('mydatabase'); 
$name = "$SCRIPT_NAME"; 

$result = MYSQL_QUERY("SELECT * FROM counter WHERE (name = '$name')") or die 
("Bad query: ".mysql_error()); 
$row = mysql_fetch_array($result); 

if($row){ 
MYSQL_QUERY("UPDATE counter SET count = count+1 WHERE (name = '$name')") or die 
("Bad query: ".mysql_error()); 
$count = $row['count']; 
}else{ 
MYSQL_QUERY("INSERT INTO counter VALUES ('', '$name', '2')") or die("Bad 
query: ".mysql_error()); 
$count = '1'; 
} 

//echo $count; 
$path = 'C:/wamp/images/'; 

$url = '/images/'; 

$ending = '.gif'; 
$style = 'SBGS';
$default_style = 'black'; 
 
$style = ($style)?$style:$default_style; 

$size = GetImageSize($path. '1'.$style.$ending); 

for ($i = 0; $i < strlen($count); $i++) { 
echo "<img src="$url$count[$i]$style$ending" $size[3]>";

} 

?>


This one of my friends html extension pages

Code: Select all

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.mydash1 {
	border-bottom-width: thin;
	border-bottom-style: dashed;
	border-bottom-color: #CCCCCC;
}
.mydash2 {
	border-right-width: thin;
	border-right-style: dashed;
	border-right-color: #CCCCCC;
	position: static;
}
-->
</style>
<style type="text/css">
<!--
.myTable {
	font-family: "Trebuchet MS", "Times New Roman";
	font-size: 12px;
	font-style: normal;
	line-height: normal;
	font-weight: lighter;
	font-variant: normal;
	text-transform: capitalize;
	text-align: justify;
	text-indent: 10px;
	display: block;
	position: static;
	height: auto;
	width: auto;
	left: auto;
	top: auto;
	text-decoration: none;
}
.mylink {
	text-decoration: none;
}
.myTop1 {
	font-family: Georgia, "Times New Roman", Times, serif;
	font-size: xx-large;
	font-style: normal;
	line-height: normal;
	font-weight: bolder;
	font-variant: normal;
	text-transform: none;
	color: #99CCFF;
	border-bottom-width: thin;
	border-bottom-style: none;
	border-bottom-color: #CCCCCC;
}
-->
</style>
<style type="text/css">
<!--
.myMid1 {
	font-family: "Trebuchet MS", "Times New Roman";
	font-size: 12px;
	text-align: left;
	text-indent: 5pt;
	vertical-align: text-top;
	display: inline;
	color: #999999;
}
-->
</style>
</head>

<body>

<table width="770" border="0" cellpadding="0" cellspacing="0">
  <!--DWLayoutTable-->
  <tr align="center" valign="middle"> 
    <td class="myTop1" height="54" colspan="2">All Medical Supply</td>
  </tr>
  <tr> 
    <td height="13" colspan="2" valign="top" class="mydash1"><!--DWLayoutEmptyCell-->&nbsp;</td>
  </tr>
  <tr> 
    <td  class="mydash2" width="163" height="466" valign="middle"> <table class="myTable" width="100%" cellpadding="0" cellspacing="0">
        <tr> 
          <td class="myTable"><a class="mylink" href="index.html" target="_parent">Home</a></td>
        </tr>
        <tr> 
          <td class="myTable">&nbsp;</td>
        </tr>
        <tr> 
          <td class="myTable"><a class="mylink" href="count3.php" target="_parent">Install</a></td>
        </tr>
        <tr> 
          <td class="myTable">&nbsp;</td>
        </tr>
        <tr> 
          <td class="myTable"><a class="myTable" href="contact%20us.php" target="_parent">Contact 
            us</a></td>
        </tr>
        <tr> 
          <td class="myTable">&nbsp;</td>
        </tr>
      </table></td>
    <td width="607" valign="middle" > 
	</tr>
</table>
<script type="text/javascript" src="myCount.php"></script> 
 </div>
</body>
</html>
What I want is one the friend view his page in a browser he would see my counter on his page.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Your script appears to echo HTML. Your friend is using Javascript to parse your script's output. These don't mix.
Nanaosei
Forum Newbie
Posts: 9
Joined: Sat Sep 22, 2007 7:01 pm

Post by Nanaosei »

How would you suggust I do this with changing my friend page extension to php.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Nanaosei wrote:How would you suggust I do this with changing my friend page extension to php.
Have your script output only the counter image, with correct header info.

Then your friend could insert the counter with a simple image tag.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Only if they are local to each other.. and even then, it's not required. Your script needs to return Javascript.
Nanaosei
Forum Newbie
Posts: 9
Joined: Sat Sep 22, 2007 7:01 pm

Post by Nanaosei »

We are not local.
Nanaosei
Forum Newbie
Posts: 9
Joined: Sat Sep 22, 2007 7:01 pm

Post by Nanaosei »

How could my script return a javascript
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Nanaosei wrote:How could my script return a javascript
Instead of echoing HTML, you would echo Javascript.
Nanaosei
Forum Newbie
Posts: 9
Joined: Sat Sep 22, 2007 7:01 pm

Post by Nanaosei »

The image tag I am echoing I save in a variable and echo a javascript of this variable like this:

Code: Select all

echo "document.write($myDisplay)";
but it does not
work on the inex.html page.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What's $myDisplay?
Nanaosei
Forum Newbie
Posts: 9
Joined: Sat Sep 22, 2007 7:01 pm

Post by Nanaosei »

the image tag I was echoing before. I stored it in $myDisplay
Post Reply