Chris Stormer
asked on
php echo error... why? easy easy question for someone who knows...
echo "<FORM ACTION='process_addkeyword .php' METHOD=POST>\n";
echo "<div>New Keyword: <INPUT type="text" name="keyword" /></div>\n";
$sCategoryList = "SELECT DISTINCT sCategoryName FROM sCategories ORDER BY sCategoryName";
$sCategoryResult = mysql_query($sCategoryList ) or die("Couldn't execute query.");
I get an error on the second line
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'
I'm trying to do an html form here.. i think this is probably rediculously easy to fix and that I'm missing the finner points of echo .. could someone enlighten me here..
echo "<div>New Keyword: <INPUT type="text" name="keyword" /></div>\n";
$sCategoryList = "SELECT DISTINCT sCategoryName FROM sCategories ORDER BY sCategoryName";
$sCategoryResult = mysql_query($sCategoryList
I get an error on the second line
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'
I'm trying to do an html form here.. i think this is probably rediculously easy to fix and that I'm missing the finner points of echo .. could someone enlighten me here..
cstormer,
The problem is the quote marks that are used in the tag with the attributes. You should make the line like this ...
echo "<div>New Keyword: <INPUT type=\"text\" name=\"keyword\" /></div>\n";
The back slash will comment the double quote so that it doesn't close the string. You could also use a line like this replacing the beginning and ending double quote with a single quote.
echo '<div>New Keyword: <INPUT type="text" name="keyword" /></div>\n';
Let me know if you have a question or need more information.
b0lsc0tt
The problem is the quote marks that are used in the tag with the attributes. You should make the line like this ...
echo "<div>New Keyword: <INPUT type=\"text\" name=\"keyword\" /></div>\n";
The back slash will comment the double quote so that it doesn't close the string. You could also use a line like this replacing the beginning and ending double quote with a single quote.
echo '<div>New Keyword: <INPUT type="text" name="keyword" /></div>\n';
Let me know if you have a question or need more information.
b0lsc0tt
ASKER
ok so it's good to know i need to escape the quotes but that doesn't 100% explain the problem with this line..
{
extract($row);
echo "<option value='$sCategory'>$sCateg ory\n";
}
my query works, but it doesn't actually show anything in the drop down box that it creates.. there are 5 items in the database and it displays a 5 item drop down list that is empty.. that is kind o fhow i know the query works... it seems something is wrong with that option line.. that doesn't let the value display in a browser?
{
extract($row);
echo "<option value='$sCategory'>$sCateg
}
my query works, but it doesn't actually show anything in the drop down box that it creates.. there are 5 items in the database and it displays a 5 item drop down list that is empty.. that is kind o fhow i know the query works... it seems something is wrong with that option line.. that doesn't let the value display in a browser?
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
So I put this linke in like you said.. and I see what you mean about opening and closing the ' and concatenating the strings and variables... but
the problem is the list is still displaying empty.. it's like it kind of see's the values in the database (it makes a drop down menu of 5) but it returns blank results.. what could possibly explain this..
the problem is the list is still displaying empty.. it's like it kind of see's the values in the database (it makes a drop down menu of 5) but it returns blank results.. what could possibly explain this..
ASKER
I feel like maybe i'm doing something wrong with my query?
$sCategoryList = "SELECT DISTINCT sCategoryName FROM scategories ORDER BY sCategoryName";
$sCategoryResult = mysql_query($sCategoryList ) or die("Couldn't execute query.");
echo '<div><SELECT name= "sCategory">\n';
while ($row = mysql_fetch_array($sCatego ryResult))
{
extract($row);
echo '<option value="' . $sCategory . '">' . $sCategory . '</option>\n';
}
$sCategoryList = "SELECT DISTINCT sCategoryName FROM scategories ORDER BY sCategoryName";
$sCategoryResult = mysql_query($sCategoryList
echo '<div><SELECT name= "sCategory">\n';
while ($row = mysql_fetch_array($sCatego
{
extract($row);
echo '<option value="' . $sCategory . '">' . $sCategory . '</option>\n';
}
ASKER
Thanks for all the help.. i went back and started again and rewrote and found what i did wrong :) Thanks!!
Your welcome! I'm glad that I could help. Thank you for the grade, the points and the fun question.
bol
bol
ASKER
$sCategoryList = "SELECT DISTINCT sCategoryName FROM scategories ORDER BY sCategoryName";
$sCategoryResult = mysql_query($sCategoryList
echo '<div><SELECT name= "sCategory">\n';
while ($row = mysql_fetch_array($sCatego
{
extract($row);
echo "<option value='$sCategory'>$sCateg
}
echo '</select>';
My dropdown list is blank... it drops the correct number of fields but there is nothing in the list.. any thoughts?