Current location: Hot Scripts Forums » Programming Languages » PHP » pls help this newbie!!!


pls help this newbie!!!

Reply
  #1 (permalink)  
Old 08-15-08, 12:19 AM
gtg's Avatar
gtg gtg is offline
New Member
 
Join Date: Aug 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
pls help this newbie!!!

I am a total newbie to programming..so having a hard time as an intern
I tried to create a program that can export data from mysql into an ___.input file (tab delimited file) for use on amazon mech turk.

Now, this is my program (unsure if it is fully correct)
__________________________________________________ _______________
PHP Code:

<?php
$HIT_SIZE
=20;
$MIN_ID=901;
$MAX_ID=1200;

$host"*****";
$user "****";
$pass "******";
$database "***";
$designClass="D6";

$linkID mysql_connect($host$user$pass) or die("Could not connect to host.");
mysql_select_db($database$linkID) or die("Could not find database.");

$query1="SELECT * from patent_extract";
$result mysql_query($query1) or die("Could not carry out query");

$fp fopen("patentnum.input""a")or die("can't open file"); 

while(
$row mysql_fetch_array($result)) { 
fwrite($fp"insert into table ".
"values ('$row[col1]', '$row[col2]','$row[col3]')\n");
}

fclose($fp); 
?>
__________________________________________________ _______________

And when I try to run the php script in Windows cmd, ( C:/PHP/PHP.EXE -f c:/users/gtg/desktop/yes.php)

I get this message...

"Warning: fopen(patentnum.input): failed to open stream: Invalid argument in C:\Users\gtg\Desktop\yes.php on line 18 "

1) Is my program correct?
2) Why can't I open the file?

Thanks!

Last edited by Nico; 08-15-08 at 02:16 AM. Reason: Please use [php] wrappers when posting PHP code.
Reply With Quote
  #2 (permalink)  
Old 08-17-08, 10:00 AM
algorithmetics algorithmetics is offline
Newbie Coder
 
Join Date: Aug 2008
Location: Pittsburgh, PA
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Try specifying whether to open the file in text or binary mode, e.g.

PHP Code:

fopen("patentnum.input","ab"
or

PHP Code:

fopen("patentnum.input","at"
Binary mode is better for portability reasons: http://www.php.net/fopen

Last edited by algorithmetics; 08-17-08 at 10:06 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pls help website problem! iangarrinud CSS 1 01-03-08 01:48 PM
Newbie here Katilpz New Members & Introductions 2 12-30-06 11:17 AM
Newbie webbie tolongges New Members & Introductions 3 09-13-04 05:11 AM
perl/cgi newbie. hangman.cgi script adding html-like code on web and other trouble Arowana Perl 12 11-13-03 02:24 PM


All times are GMT -5. The time now is 07:53 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.