Bug in mysql or something else...

Bug in mysql or something else...

offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

when i try to create a table with space between the name it says that there is an error. I was reading some stuff and i found a post on some forum and it says that when u wrote "create table 'table1 ' (x int) " it give a error and that this is a bug in mysql, but the post was wroted in 2004, so now this bug is fixed.

now i m trying to create table with space between the name something like "table one", and this gives a error.
Ok maybe in mysql manager there is a rule that we shouldnt write spaces between the name.
But maybe this can be fixed when we will integrate in php.

... <input type="text" name="table"> <input type="text" name="name"> <input type="text" name="question"> ... $query = "create table $table (ID int(10) unsigned not null primary key auto_increment, name varchar(64), question text)";

the input text box should be something a short version of the question

let me give a example;

i will write "How to..." in the first text box, this mean that the table name should be "How to..." , but it will return an error because the space between "How" and "to...".
second i will write my name(this is not very important) in the second text box
and third i will write the hole question in the third text box.

so my point is, is this a bug or there is a function or something like that for this problem?

u can write in serbian if u want



Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
offline
  • Peca  Male
  • Glavni Administrator
  • Predrag Damnjanović
  • SysAdmin i programer
  • Pridružio: 17 Apr 2003
  • Poruke: 23211
  • Gde živiš: Niš

First, I never seen table with a 'blank' character in name.
I think it is not by SQL standard at all.
Use _ instead blank character... for example: table_one

Second, try:
$query = "create table ".$_POST['table']." (ID int(10) unsigned not null primary key auto_increment, name varchar(64), question text)";
I assume you use POST method in <form>.



offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

Peca ::First, I never seen table with a 'blank' character in name.
I think it is not by SQL standard at all.
Use _ instead blank character... for example: table_one


yes i know that i should underscore instead a space.

Peca ::
Second, try:
$query = "create table ".$_POST['table']." (ID int(10) unsigned not null primary key auto_increment, name varchar(64), question text)";
I assume you use POST method in <form>.

Yes the method is POST.

Imagine a forum, and u want to make a new post on that forum, and when u create a new post with that u r creating the table which will hold the questions , answers of the users.
So u want the name of that post to be, let's say "How to make ....", ofcourse it will be stupid to write "How_to_make_...". That is my point.

offline
  • Peca  Male
  • Glavni Administrator
  • Predrag Damnjanović
  • SysAdmin i programer
  • Pridružio: 17 Apr 2003
  • Poruke: 23211
  • Gde živiš: Niš

Totaly wrong logic.
You have to insert data to one or two [max three] tables that will contain all posts, questions and answers.
Creating a table for every post is totaly insane, brother Smile

offline
  • PHP developer
  • Pridružio: 22 Mar 2006
  • Poruke: 3760
  • Gde živiš: 127.0.0.1

I agree with Peca, creating a table for every post (or even topic) would be totally insane Very Happy

You can always use str_replace(); if you want to replace spaces with underscores... something like:

$title = str_replace(" ", "_", $title);

and you'll get "How_to_make..." instead of "How to make..."

offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

Peca ::Totaly wrong logic.
You have to insert data to one or two [max three] tables that will contain all posts, questions and answers.
Creating a table for every post is totaly insane, brother Smile


ok i know u are right. just tell me when i click 'nova tema', i m creating a new table or a new record?

Rastafarii ::I agree with Peca, creating a table for every post (or even topic) would be totally insane Very Happy

You can always use str_replace(); if you want to replace spaces with underscores... something like:

$title = str_replace(" ", "_", $title);

and you'll get "How_to_make..." instead of "How to make..."


damn man where were u till now Smile tnx for the tip

offline
  • Pridružio: 18 Apr 2003
  • Poruke: 8134
  • Gde živiš: U kesici gumenih bombona...

@ Rutix

When you click 'Nova tema' you are creating new record.

offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

ok, tnx man

Ko je trenutno na forumu
 

Ukupno su 1153 korisnika na forumu :: 36 registrovanih, 8 sakrivenih i 1109 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 3466 - dana 01 Jun 2021 17:07

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: A.R.Chafee.Jr., ajo baba, ArchaBasha, darkangel, darkojbn, Darkoniii_94, Dežurni pod palubom, Dimitrije Paunovic, dushan, FOX, Frunze, goxin, Griffon vulture, kikisp, koom0001, kybonacci, mercedesamg, Metanoja, milenko crazy north, milutin134, mnn2, mocnijogurt, naki011, nuke92, pein, procesor, Rogan33, Singidunumac, Sirius, stegonosa, Trpe Grozni, VJ, wolf431, YugoSlav, zixmix, šumar bk2