Page 1 of 1
some questions about php write into mysql
Posted: Sun Feb 08, 2009 12:01 pm
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...
Re: some questions about php write into mysql
Posted: Sun Feb 08, 2009 8:26 pm
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.
Re: some questions about php write into mysql
Posted: Mon Feb 09, 2009 10:18 am
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...
Re: some questions about php write into mysql
Posted: Mon Feb 09, 2009 12:49 pm
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.
Re: some questions about php write into mysql
Posted: Mon Feb 09, 2009 7:39 pm
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...
