-
mysql php query problem
I'm working on a database to hold reviews. At the moment I use PHP to make a list of names in a component in flash. When you click on a name it does this:
stuff.name= c.getSelectedItem().label;
stuff.sendAndLoad("http://website/retrieve.php",info,"POST");
I know the name is being sent to PHP but I'm having problems with it sending it back. It's the WHERE argument, I've tried different things but they haven't worked:
<?PHP
$link = mysql_connect("localhost","username","password");
mysql_select_db("table");
$result = mysql_query("SELECT * FROM things WHERE ??????");
$line = mysql_fetch_row($result);
echo "<?xml version=\"1.0\"?>\n";
echo "<review>\n";
echo "<name>" . $line["name"] . "</name>\n";
echo "<review>" . $line["review"] . "</review>\n";
echo "<reviewer>" . $line["reviewer"] . "</reviewer>\n";
echo "<rating>" . $line["rating"] . "</rating>\n";
echo "</review>\n";
mysql_close($link);
?>
I don't know if this is the right sort of thing to use. I thought doing something like name=$_POST["name"] but it hasn't worked.
Anybody with any suggestion about anything would be great.
Thanks in advance.
-
well, this may be totally unrealted, but the correct way to insert things into WHERE is:
WHERE `name` = '".$_POST["name"]."'
Any $_POST variable must be includes using ., ditto on _SESSION, $_GET, etc.
Also, strings must be surrounded with ' in SQL
-
I still get an output of:
<?xml version="1.0"?><review><name /><review /><reviewer /><rating /></review>
Can anyone help?
-
I mean there's no content.
-
I use this format:
<?
echo "<?xml version=\"1.0\"?>\n";
$sql = "QUERY";
$query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());
while($result = mysql_fetch_array($query)){
$data1 = $result["COLUMN1"];
$data2 = stripslashes($result["COLUMN2"]);
?>
<author><?= $author ?></author>
etc...
<? } ?>
Where you would put your xml declaration outside of it.
What are the column names? do you need help making the query itself?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|