By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,506 Members | 1,876 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,506 IT Pros & Developers. It's quick & easy.

how to insert excel file to mysql?

P: 29
Can i ask how to insert a file into mysql?

what the different between basename, getElementsByTagName, DOMdocument and $_FILES?

how to apply it?

thz.
Sep 2 '09 #1
Share this Question
Share on Google+
10 Replies


Dormilich
Expert Mod 5K+
P: 8,639
use SQL. there’s a tutorial here. (or look for a tutorial using your favourite search engine)
Sep 2 '09 #2

P: 29
ok, i hv seen the tutorial aldy,

but can i ask a question is 'mysqli'
if i apply mysqli, it will face the problem
Fatal error: Call to undefined function: mysqli_connect() in c:\program files\easyphp1-8\www\ll\image\add_file.php on line 9

if i change mysqli to mysql
the problem will come out such as

Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in c:\program files\easyphp1-8\www\ll\image\add_file.php on line 12

Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in c:\program files\easyphp1-8\www\ll\image\add_file.php on line 13

Warning: mysql_real_escape_string() expects parameter 1 to be string, resource given in c:\program files\easyphp1-8\www\ll\image\add_file.php on line 15

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in c:\program files\easyphp1-8\www\ll\image\add_file.php on line 21
Error! Failed to insert the file
can i ask for the solution? thz
Sep 2 '09 #3

Dormilich
Expert Mod 5K+
P: 8,639
problem 1: MySQLi is not installed on your system

problem 2: be aware that mysql_* and mysqli_* use a different parameter call (refer to the manual)
Sep 2 '09 #4

P: 29
still cant get it,
can tell more detail, thz.
Sep 2 '09 #5

Markus
Expert 5K+
P: 6,050
The errors are very self-explanatory. You're providing the wrong type of arguments to the functions: mysql_real_escape_string() expects a string - you're giving it a resource instead; mysql_query() allows for a resource-link generated by mysql_connect(), however, you're giving it something else.

Read the documentation on these functions.

http://php.net/mysql
Sep 2 '09 #6

Frinavale
Expert Mod 5K+
P: 9,731
Dreamy,

Please make sure that you have the mysqli extension installed before trying to use it. Once it's installed I'm sure you'll be able to use it properly.

:)

-Frinny
Sep 2 '09 #7

P: 29
ok, can i ask another question about DOMdocument,

if i put like this

Expand|Select|Wrap|Line Numbers
  1. $dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
  2. $rows = $dom->getElementsByTagName( 'Row' );
it come out error
Fatal error: Undefined class name 'domdocument' in c:\

so,
izit i need add...
can tell me? thz
Sep 4 '09 #8

Dormilich
Expert Mod 5K+
P: 8,639
load() is not a static method, you have to create the DOMDocument object first.
Expand|Select|Wrap|Line Numbers
  1. $do = new DOMDocument;
  2. $do->load(…);
Sep 4 '09 #9

Markus
Expert 5K+
P: 6,050
What PHP version are you using? On top of Dorm's answer, it sounds like you're using PHP 4, which doesn't have DOMDocument. Check out DOM XML for PHP4 (which is terrible, btw), and consider upgrading to PHP5. Developing for PHP4 should've stopped along time ago.

Mark.
Sep 4 '09 #10

P: 29
i hv done the upload file with the csv type,
but now,
after upload a csv file,
data hv insert into database
izit can delete a row data from database?
Sep 8 '09 #11

Post your reply

Sign in to post your reply or Sign up for a free account.