Reply to Re: [PHP] Re: please shed some light on SQLsyntax error

Your name:

Reply:


Posted by Stephen Leaf on 11/14/05 07:50

I believe it's proper SQL syntax to use a double quote " tho for column names.
I've heard of backtick working.. but in any example I've ever seen both in
classes and on mysql and postgresql sites they always use "" I don't use ``
so I'm not sure how widely they are accepted.

Just ran a test in sqlite and postgresql `` are not accepted.

On Sunday 13 November 2005 06:31 pm, Jasper Bryant-Greene wrote:
> Bruce Gilbert wrote:
> > for the table name you mean like this?
> >
> > $table_name =" 'Contact List' ";
>
> No, backticks. I gave an example of the backtick in my email (in
> brackets). It is on the same key as the tilde, and looks like this: `
>
> Also, I would probably left $table_name as it was and put the backticks
> in the SQL statement, like this:
>
> $sql = "INSERT INTO `$table_name` values ('', '$_POST[f_name]', [...]
>
> Jasper
>
> > On 11/13/05, Jasper Bryant-Greene <jasper@album.co.nz> wrote:
> >> Bruce Gilbert wrote:
> >>>> You would need to show us the SQL that was causing that error.
> >>>> Otherwise it is fairly meaningless.
> >>>
> >>> hope this helps...
> >>>
> >>> <?
> >>>
> >>> //check for required form variables
> >>> if ((!$_POST[f_name]) || (!$_POST[l_name])) {
> >>
> >> Unrelated, but you should have quotes here. Like $_POST['f_name']
> >>
> >> header("Location:http://www.inspired-evolution.com/show_addcontact.php"
> >>);
> >>
> >> There should also probably be a space between the : and the start of the
> >> URL here.
> >>
> >>> exit;
> >>> }else {
> >>> //if form variables are present,start a session
> >>> session_start();
> >>> }
> >>>
> >>> //check for validity of user
> >>> if ($_SESSION[valid] != "yes") {
> >>
> >> Again, quotes on the array subscript.
> >>
> >>> header("Location:http://www.inspired-evolution.com/contact_menu.php");
> >>
> >> And space between colon and URL here.
> >>
> >>> exit;
> >>> }
> >>>
> >>> //set up table and database names
> >>> $db_name ="bruceg_contactlist";
> >>> $table_name ="Contact List";
> >>>
> >>> //connect to server and select database
> >>> $connection =
> >>
> >> @mysql_connect("69.90.6.198","database_username","password")
> >>
> >>> or die(mysql_error());
> >>> $db = @mysql_select_db($db_name,$connection) or die(mysql_error());
> >>>
> >>> //build and issue query
> >>> $sql = "INSERT INTO $table_name values ('', '$_POST[f_name]',
> >>
> >> You'll be wanting to put backticks (`) around the table name, because it
> >> contains a space.
> >>
> >> Jasper
> >
> > --
> >
> > ::Bruce::

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация