PDA

View Full Version : question


porkchop
07-24-2004, 10:01 PM
i get this error while running this script

Query failed : 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 ''char'' at line 1
this is the file
http://s94422120.onlinehome.us/testing.txt


help?

raf
07-25-2004, 10:24 AM
Welcoe here!

'char' is a reserved word in almost all sql-versions. Change the tablename or use backticks around it. Like
$query = "SELECT zeny FROM `char`";

porkchop
07-25-2004, 10:40 PM
Welcoe here!

'char' is a reserved word in almost all sql-versions. Change the tablename or use backticks around it. Like
$query = "SELECT zeny FROM `char`";
thank you so much! worked like a charm :D

now i have one more question. is it possible to query something within a table but to hide it when it's processed into html?

perhaps i can change this somehow?

echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";

raf
07-25-2004, 11:54 PM
I don't quite understand the question.

Do you mean hiding one of the returned columns?
Then you can use something like (suppose we have column 'secret' that we don't wan't to display):

echo "<table>\n";
while ($line = mysql_fetch_assoc($result)) {
echo "\t<tr>\n";
foreach ($line as $col_var=>$col_value) {
if ($col_var!='secret'){
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
}
echo "</table>\n";

porkchop
07-26-2004, 12:19 AM
I don't quite understand the question.

Do you mean hiding one of the returned columns?
Then you can use something like (suppose we have column 'secret' that we don't wan't to display):

echo "<table>\n";
while ($line = mysql_fetch_assoc($result)) {
echo "\t<tr>\n";
foreach ($line as $col_var=>$col_value) {
if ($col_var!='secret'){
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
}
echo "</table>\n";

thank you sir! worked like a charm :)

raf
07-26-2004, 02:21 AM
No problem :thumbsup:

Happy coding !

porkchop
07-26-2004, 03:13 AM
No problem :thumbsup:

Happy coding !
blah... i must be becoming a nuisance...

is there a online resource where i can learn about the <td> tag? like waht does \n and \t do?

I find it really hard to organize my data around not knowing jack about the tables in php

raf
07-26-2004, 01:59 PM
there is no such thing as php-tables.

In your code, the php generates HTML that is then sent to the browser. There should be plenty of tutorials on using tables in html (www.hotscripts.com, http://www.w3schools.com, google ...)

\n and \t doen't have any visible effect. But if you look at the source of the page in your browser, then you'll see that \n will create a newline in he source, and \t will create a tab.

But they are not required (i neverusit since i hardly ever take alook at the source in my browser