Help with master detail page

reglus

New Member
Messages
62
Reaction score
0
Points
0
Hey i am creating a master detail page in dreamweaver and using php.

I have made it but i have an error that is when i use the page and then click on one of the links in the dynamic table it is meant to show me records from my mysql database. However it is just coming up with this error message.

(You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Name = 'Another test'' at line 1)

Please somone help.
 

cowctcat

New Member
Messages
401
Reaction score
0
Points
0
It means exactly what it says. You have an error on your sql syntax. I would need to see it in order to help.
 

reglus

New Member
Messages
62
Reaction score
0
Points
0
ah ok but where would i find the syntax?

sorry about this i only just learned php so my next move is php.
 

konekt

New Member
Messages
100
Reaction score
0
Points
0
In php you should look for $mysql_query somewhere around line 1 (see that the error points to line 1).
 

reglus

New Member
Messages
62
Reaction score
0
Points
0
Ah ok thanks.

This below is the syntax for the master detail page that displays the links thats show the record. Its is for this webpage: http://www.lookgoodfood.x10hosting.com/Recipe/recipeindex.php

Code:
<?php require_once('../Connections/connectDB.php'); ?>
<?php
mysql_select_db($database_connectDB, $connectDB);
$query_reciperecordsheet = "SELECT * FROM recipe";
$reciperecordsheet = mysql_query($query_reciperecordsheet, $connectDB) or die(mysql_error());
$row_reciperecordsheet = mysql_fetch_assoc($reciperecordsheet);
$totalRows_reciperecordsheet = mysql_num_rows($reciperecordsheet);
?>
The syntax below this is the one for the page that displays the results that were clicked on.

Code:
<?php require_once('../Connections/connectDB.php'); ?><?php
mysql_select_db($database_connectDB, $connectDB);
$recordID = $_GET['recordID'];
$query_DetailRS1 = "SELECT * FROM recipe WHERE Recipe Name = '$recordID'";
$DetailRS1 = mysql_query($query_DetailRS1, $connectDB) or die(mysql_error());
$row_DetailRS1 = mysql_fetch_assoc($DetailRS1);
$totalRows_DetailRS1 = mysql_num_rows($DetailRS1);
?>
I think that is what you meant.
 

Livewire

Abuse Compliance Officer
Staff member
Messages
18,169
Reaction score
216
Points
63
Standard mysql error as a matter of fact.

Code:
$query_DetailRS1 = "SELECT * FROM recipe WHERE Recipe Name = '$recordID'";
Is what you have.

Here's the problem - Recipe Name is, as far as MySQL is concerned, not what it's looking for. It's looking for <source> = <value>, you're providing what it thinks is <column> <column> = <value>, which it can't do - it wants <source> = <value>, and it won't really change at all.

Theres two options:

Code:
$query_DetailRS1 = "SELECT * FROM recipe WHERE Name = '$recordID'";
Cut out the word Recipe just before Name which is fine as long as you only select stuff from recipe, or...

Code:
$query_DetailRS1 = "SELECT * FROM recipe WHERE Recipe.Name = '$recordID'";
Put a dot instead of a space between Recipe and Name. That dot changes how mysql looks for the source to <table>.<column>, so you're basically saying "select everything from recipe where the name column in the table recipe equals <value>".


That should fix that error at the very least; it might not fix it completely if there happen to be others, but that should fix that particular sql error.
 
Top