TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   plz a select error (http://www.talkphp.com/absolute-beginners/1917-plz-select-error.html)

webtuto 01-09-2008 07:09 PM

plz a select error
 
hi
what is the problem in this code --->

PHP Code:

<?php
include("config.php");
$get=$_GET['cat'];
$sql="SELECT * FROM `tuto` where group='$get' ";
$res mysql_query($sql) or die('Database error: ' mysql_error());
while(
$row=mysql_fetch_array($res)) {
   echo 
"The title is ".$row[title]."<br>";
   echo 
"The resume is ".$row[resume]."<br>";
   echo 
"Written on ".$row[date]."<br><br><br><br>";
}
?>

the error --->

Database error: 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 'group='Photoshop'' at line 1

RobertK 01-09-2008 07:16 PM

Can you tell us what the row is like in the actual table? IE, just a dump of the rows in the table. This way we can see how you have it set up.

I'm not that great with SQL yet, so this information would help me.

webtuto 01-09-2008 07:17 PM

what row ?
if u mean the name it is "group"

buggabill 01-09-2008 07:18 PM

I may be wrong...Could it be because group is a reserved word?

Try this maybe:

PHP Code:

<?php
include("config.php");
$get=$_GET['cat'];
$sql="SELECT * FROM `tuto` where `group`='$get' ";
$res mysql_query($sql) or die('Database error: ' mysql_error());
while(
$row=mysql_fetch_array($res)) {
   echo 
"The title is ".$row[title]."<br>";
   echo 
"The resume is ".$row[resume]."<br>";
   echo 
"Written on ".$row[date]."<br><br><br><br>";
}
?>


RobertK 01-09-2008 07:25 PM

Quote:

Originally Posted by buggabill (Post 8053)
I may be wrong...Could it be because group is a reserved word?

Knew I looked past something. ;-)

Nevermind webtuto, I think this is it.

webtuto 01-09-2008 07:31 PM

lol thanks anyway robert i solved the problem :d

TlcAndres 01-09-2008 08:47 PM

On a note not relevant to the problem

PHP Code:

 $row['resume'

is faster then
PHP Code:

 $row[resume

also use mysql_real_escape_string() on the $_GET.

webtuto 01-10-2008 12:27 AM

thanks ;)........


All times are GMT. The time now is 11:57 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0