some questions about php write into mysql

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
abel
Forum Newbie
Posts: 6
Joined: Sun Feb 08, 2009 11:47 am

some questions about php write into mysql

Post by abel »

Moved by moderator to Miscellaneous.

i want to write some data into database.i can enter like:
...
$sql="insert into 'test'.'user'('name','age','sex','id')values('example','20','male',NULL)";
$result=mysql_query($sql);
if($result){
echo "done!";
}else{
echo "failed!";
}
...
then browser shows "failed!"

i trid to change it like:
...
$sql="insert into `test`.`user`(`name`,`age`,`sex`,`id`)values('example','20','male',NULL)";
$result=mysql_query($sql);
if($result){
echo "done!";
}else{
echo "failed!";
}
...
then display "done!"
and insert successfully...

i just wanna know...
what's the difference between them..
symbols caused??

the end, thanks for help first...
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: some questions about php write into mysql

Post by califdon »

The only acceptable character to enclose table names or field names is the "back-tick" ( ` ). You cannot substitute the single quote (apostrophe) ( ' ). It is a completely different character. In fact, you don't need to enclose table names or field names at all unless the names are key words or could be confused.
abel
Forum Newbie
Posts: 6
Joined: Sun Feb 08, 2009 11:47 am

Re: some questions about php write into mysql

Post by abel »

thanks a lot for your reply..
i got it...
and i have a query yet..
the database which i created...
also..i inserted contents into this..
then i exported it..when i tried to import it again..error said with:

No data was received to import. Either no file name was submitted, or the file size exceeded the maximum size permitted by your PHP configuration. See FAQ 1.16.

even though.. i downloaded one on internet..and imported it..also showed like above...
i am sure the file size is acceptable...
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: some questions about php write into mysql

Post by califdon »

abel wrote:thanks a lot for your reply..
i got it...
and i have a query yet..
the database which i created...
also..i inserted contents into this..
then i exported it..when i tried to import it again..error said with:

No data was received to import. Either no file name was submitted, or the file size exceeded the maximum size permitted by your PHP configuration. See FAQ 1.16.

even though.. i downloaded one on internet..and imported it..also showed like above...
i am sure the file size is acceptable...
I don't know what you mean when you say "exported" and "import". There was nothing in the code you showed that involved importing or exporting or files of any kind. If you explain what you did, maybe I can help you.
abel
Forum Newbie
Posts: 6
Joined: Sun Feb 08, 2009 11:47 am

Re: some questions about php write into mysql

Post by abel »

oh sorry...
this question is not about php code.
it's about phpmyadmin..
i mean that i can't import sql file through phpmyadmin...
i hope you will understand what i mean... :(
Post Reply