...

View Full Version : A href tag and Mysql qery (Master page)



Cyber_type
04-29-2009, 08:28 AM
Hello.
trying to put a variable trough an URL, $_GET but at this point have an error.

echo "<td><a href="movie_details.php?art_desc=$art_desc"
title="Find out more about $art_desc><" . $art_desc . "></td>;



Parse error: parse error, expecting `','' or `';'' in D:\Program Files\EasyPHP 3.0\www\com\gallery.php on line 33

obviously something , or ; misses up but where?

bdl
04-29-2009, 08:38 AM
You're using "double quotes" to wrap your string, and within your string. Either escape the quotes in the string using a backslash, e.g.


$var= "sometimes I like to use \"double quotes\" in quoted strings";


Or simply use 'single quotes' within the string itself.

Cyber_type
04-29-2009, 09:14 AM
something like this


echo "<td><a href=showart.php?art_desc='.$art_desc.'</a></td>\n";


tried also


echo "<td><a href=showart.php?art_desc=\".$art_desc.\"</a></td>\n";

no errors but the column $art_desc doesn't display

abduraooft
04-29-2009, 09:19 AM
echo "<td><a href=showart.php?art_desc=".$art_desc."</a></td>\n";

Or

echo "<td><a href=showart.php?art_desc=\"$art_desc\"</a></td>\n"; Or more precisely

echo "<td><a href=showart.php?art_desc=\"{$art_desc}\"</a></td>\n";

Cyber_type
04-29-2009, 09:26 AM
tried but no the column $art_desc doens't display :confused:

_Aerospace_Eng_
04-29-2009, 09:52 AM
Please post your updated code. Its likely you did something wrong.

Cyber_type
04-29-2009, 10:18 AM
<html>
<head>
<title>Welcome to our Photo Gallery</title>
</head>
<body>
<p align="center">Click on any image to see it full sized.</p>
<table width="60%" border="0" cellpadding="2"
cellspacing="2" align="center">
<tr>
<td align="left">Image</td>
<td align="left">Description</td>
<td align="left">Categoria</td>
</tr>
<?php
require_once ("misc.php");
require_once ("Connexion.php");
require_once ("ExecRequete.php");

$connexion = Connexion(NOM, PASSE, BASE, SERVEUR);
$result = ExecRequete("SELECT ALL artigos.*, cat_nome FROM artigos INNER JOIN categorias ON artigos.cat_id = categorias.cat_id", $connexion);
while ($rows = mysql_fetch_array($result)) {
extract($rows);
echo "<tr>\n";
echo "<td><a href='../images/{$rows['art_nome']}'
border='0'>
<img src='../images/{$rows['art_nome']}' border='0'
width='100' height='80'></a></td>\n";
echo "<td><a href=showart.php?art_desc=\"{$art_desc}\"</a></td>\n";
echo "<td>" . $cat_nome . "</td>\n";
echo "</tr>\n";
}
?>
</table>
</body>
</html>


no errors on displaying the page just the column $art_desc won't display

Cyber_type
04-29-2009, 11:43 AM
tried this



while ($rows = mysql_fetch_array($result)) {
//extract($rows);

$art_nome = $rows['art_nome'];
$art_desc = $rows['art_desc'];
$cat_nome = $rows['cat_nome'];

echo "<tr>\n";
echo "<td><a href='../images/{$rows['art_nome']}'
border='0'>
<img src='../images/{$rows['art_nome']}' border='0'
width='100' height='80'></a></td>\n";
echo "<td><a href=showart.php?art_desc=\"{$art_desc}\"</a></td>\n";
echo "<td>" . $cat_nome . "</td>\n";
echo "</tr>\n";
}


trying the variables with "echo $art_nome" and so it display it but with the <a href> tag it won't.

Cyber_type
04-29-2009, 03:30 PM
tried to pu an echo between the <a></a> tag but nothing


echo "<td><a href=showart.php?art_desc= echo " .$art_desc. "</a></td>\n";

someone have an idea?

Cyber_type
04-29-2009, 05:44 PM
Done!!
Here's the good code


echo '<td><a href="showart.php?art_desc='.$art_desc.'">'.$art_desc."</a></td>\n";

bdl
04-29-2009, 07:40 PM
@Cyber_type> I'm glad you sorted it out. Do you see the mistakes you were making there?

I strongly suggest, before you go much further, that you take the time to sit and read through the PHP Language Reference (http://us.php.net/langref), especially the sections on Types (http://us.php.net/manual/en/language.types.php), Variables (http://us.php.net/manual/en/language.variables.php) and Operators (http://us.php.net/manual/en/language.operators.php).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum