Forum Moderators: coopster
Here is the code I am using: mysql_connect("db1.awardspace.com",$username,$password); $id=mysql_result($result,$page_num,"id"); echo "<table><tr><td><image src=$thumb><br>ID: $id<br>Download:<a href=$download>Download</a></td> $page_num++; The error that keeps being returned is: Parse error: parse error, unexpected T_STRING in /home/www/example.com/catalog.php on line 15 Now of course I have filled in the correct username and password and database information. That is not the problem. If anyone can help, please do so. [1][edited by: jatar_k at 10:29 pm (utc) on Feb. 10, 2006]
<html>
<body>
<?
$username="";
$password="";
$database="";
$var_array = explode("/",$PATH_INFO);
$page_num = $var_array;
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM catalog ;
$result=mysql_query($query);
$thumb=mysql_result($result,$page_num,"thumb");
$image=mysql_result($result,$page_num,"image");
$download=mysql_result($result,$page_num,"download");
<td><image src=$thumb><br>ID: $id<br>Download:<a href=$download>Download</a></td></tr></table>";
mysql_close();
?>
</body>
</html>
[edit reason] examplified [/edit]
ID Thumb Download etc.
1 [......] [......]
2 [......] [......]
Now the id # is stored in the variable $page_num which is determined by the url query string. The problem is that I need to add 1 to it everytime it is executed. That is what this string was for:
$page_num++;
Except when the screen appears, I get ++; as plain text and so therefore the ID never changes and I could never have it display a different image other than the one associated with ID1.
I'm not even sure if ++ is valid in PHP, if it isn't use
$page_num=$page_num+1;
echo "<table><tr><td><image src=$thumb><br>ID: $id<br>Download:<a href=$download>Download</a></td> $page_num
<td><image src=$thumb><br>ID: $id<br>Download:<a href=$download>Download</a></td></tr></table>";
<edit>
You may also want to break that echo into two lines to make it more readable.
</edit>
[edited by: Dijkgraaf at 10:08 pm (utc) on Feb. 10, 2006]
echo "<table><tr><td><image src=$thumb><br>ID: $id<br>Download:<a href=$download>Download</a></td>";
$page_num=$page_num+1;
echo"<td><image src=$thumb><br>ID: $id<br>Download:<a href=$download>Download</a></td></tr></table>";
so it is supposed to display the first product then add 1 to the $page_num variable then when it adds the second one it is supposed to have all the details of the second product. But instead it repeats the first.
[edited by: itechdesigns at 10:14 pm (utc) on Feb. 10, 2006]
P.S. You may want to edit out your domain name, and replace it with www.example.com as posting your URL's is against the terms of service of this forum.
If you don't edit it out, one of the admins will :-)
echo "<table><tr><td><image src=$thumb><br>ID: $id<br>Download:<a href=$download>Download</a></td>";
$page_num=$page_num+1;
echo"<td><image src=$thumb><br>ID: $id<br>Download:<a href=$download>Download</a></td></tr></table>";
so it is supposed to display the first product then add 1 to the $page_num variable then when it adds the second one it is supposed to have all the details of the second product. But instead it repeats the first. "
-Is that the question to which you answered:
"Try
$var_array = explode("/",$_SERVER['PATH_INFO']);
the way you had it is dependant on a server configuration setting that is better left off."
-If not could you please try this question out?
echo"<table cellspacing=4><tr><td><image src=$thumb><br>ID: $id<br><a href=$download><image src="http://example.com/images/button(download).bmp" border=0 srcover="http://example.com/images/button(download)press.bmp"></a></td>";
If you see what the problem is then please help out.
Oh and by the way, the srcover refers to a javascript used earlier.
[edited by: jatar_k at 11:46 pm (utc) on Feb. 10, 2006]
[edit reason] examplified [/edit]
when you start your string to be echo'ed
echo "
this set of quotes will be closed at the next set of double quotes
echo"<table cellspacing=4><tr><td><image src=$thumb><br>ID: $id<br><a href=$download><image src="http://example.com/images/button(download).bmp" border=0 srcover="http://example.com/images/button(download)press.bmp"></a></td>";
you need to, either, use single quotes inside your double quoted string like so
echo"<table cellspacing=4><tr><td><image src=$thumb><br>ID: $id<br><a href=$download><image src='http://example.com/images/button(download).bmp' border=0 srcover='http://example.com/images/button(download)press.bmp'></a></td>";
that way you can just jam your variables inside your double quoted string and they will be resolved
or
you put single quotes around the outside. You can then use double quotes inside if needed but then the vars won't be resolved so you could do it this way
echo '<table cellspacing=4><tr><td><image src="',$thumb,'"><br>ID: ',$id,'<br><a href="',$download,'"><image src="http://example.com/images/button(download).bmp" border=0 srcover="http://example.com/images/button(download)press.bmp"></a></td>';
that's the way I do it. The echo function allows you to use commas between seperate values to be echo'ed. You can also use the period . called the concatenation operator, but I have found the comma is faster.
Example:
echo"<table cellspacing=4><tr><td><image src=$thumb><br>ID: $id<br><a href=$download>";
?>
<image src='http://www.examplesite.com/images/buttondown.bmp' border=0 srcover='http://www.examplesite.com/images/buttondownpress.bmp'>
<? echo"</a></td>";?>
The javascript code works in normal html files. The srcover points to part of the coding in imagerollover.js.
thanks again and again