Page 1 of 2
image counter
Posted: Sat Sep 22, 2007 7:13 pm
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.
Posted: Sat Sep 22, 2007 7:42 pm
by feyd
Are you asking a question, or simply making an odd introduction of yourself?
image counter
Posted: Sat Sep 22, 2007 7:46 pm
by Nanaosei
I really need help and I am asking a question
Posted: Sat Sep 22, 2007 7:48 pm
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.
Posted: Sat Sep 22, 2007 8:02 pm
by Nanaosei
feyd | Please use 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--> </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"> </td>
</tr>
<tr>
<td class="myTable"><a class="mylink" href="count3.php" target="_parent">Install</a></td>
</tr>
<tr>
<td class="myTable"> </td>
</tr>
<tr>
<td class="myTable"><a class="myTable" href="contact%20us.php" target="_parent">Contact
us</a></td>
</tr>
<tr>
<td class="myTable"> </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.
feyd | Please use 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]
Posted: Sat Sep 22, 2007 8:16 pm
by feyd
Your script appears to echo HTML. Your friend is using Javascript to parse your script's output. These don't mix.
Posted: Sat Sep 22, 2007 8:22 pm
by Nanaosei
How would you suggust I do this with changing my friend page extension to php.
Posted: Sat Sep 22, 2007 8:27 pm
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.
Posted: Sat Sep 22, 2007 8:28 pm
by feyd
Only if they are local to each other.. and even then, it's not required. Your script needs to return Javascript.
Posted: Sat Sep 22, 2007 8:32 pm
by Nanaosei
We are not local.
Posted: Sat Sep 22, 2007 8:34 pm
by Nanaosei
How could my script return a javascript
Posted: Sat Sep 22, 2007 10:23 pm
by feyd
Nanaosei wrote:How could my script return a javascript
Instead of echoing HTML, you would echo Javascript.
Posted: Sat Sep 22, 2007 10:38 pm
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.
Posted: Sat Sep 22, 2007 10:57 pm
by feyd
What's $myDisplay?
Posted: Mon Sep 24, 2007 11:15 pm
by Nanaosei
the image tag I was echoing before. I stored it in $myDisplay