Join us at IRC!
The important thing is not to stop questioning. - Albert Einstein
Friday, May 25, 2012
Navigation
Members Online
Total Online: 32
Web Spiders: 17
Guests Online: 32
Members Online: 0

Registered Members: 70208
Newest Member: andresuran
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

[PHP] File Read/Upload Arrays to DB

DarkMantis
Member



Posts: 192
Location: Bringing Security To You!
Joined: 23.04.06
Rank:
Elite
Posted on 24-07-09 09:31
Hi, basically I've got a scblockedript which reads data from a .txt file and saves it into an array and uploads the array of data to a database.

My problem is in the text file I have data like this:

hello/I/am/going/to/be/put/into/an/array

and that saves to an array fine, but as soon as I have another set of data to be read and saved into an array it only saves the first bit of data and stops before it reads the second bit:

hello/I/am/going/to/be/put/into/an/array

[id] => hello
[null_one] => I
[null_two] => am
[null_three] => going
[null_four] => to
[null_five] => be
[null_six] => put
[null_seven] => into
[testField] => an
[testField2] => array



If you can understand what I mean, can anyone please suggest an answer Please.

Thank you.








THE PEOPLE UNITED WILL NEVER BE DEFEATED!

don't care for money, and money's not for me,
the money fueled this empire and our racist history.
Although I'm forced to use it, the rules have all been set.
But life is not worth living when yer soul is in debt!

MONEY KILLS.
MONEY RAPES.
MONEY LIES.
MONEY HATES.
Author

RE: [PHP] File Read/Upload Arrays to DB

DarkMantis
Member



Posts: 192
Location: Bringing Security To You!
Joined: 23.04.06
Rank:
Elite
Posted on 24-07-09 09:39


<?php

if ($_FILES["file"]["error"] > 0)
{
echo "Error: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
echo "<br /><br /><br />";
}


$file = fopen($_FILES["file"]["tmp_name"], "r");

$readFile=fread($file,$_FILES["file"]["size"]);
$sortData = list(
$id,
$null_one,
$null_two,
$null_three,
$name,
$Number,
$pMonth,
$Year,
$cv,
$address,
$town,
$town,
$state,
$country,
$zipCode,
$email
)
= explode("/", $readFile);


$sortData_assoc_array=array(
'id' => $id,
'null_one' => $null_one,
'null_two' => $null_two,
'null_three' => $null_three,
'name' => $name,
'Number' => $Number,
'Month' => $Month,
'Year' => $Year,
'CV' => $cv,
'address' => $address,
'town' => $town,
'state' => $state,
'country' => $country,
'zipCode' => $zipCode,
'email' => $email
);

echo "<pre>".print_r($sortData_assoc_array,true)."</pre>";
echo "<br /><br /><br />";


/*
Uploading the Array to a database
*/


$query = sprintf("
INSERT INTO
`byte_database`.`orders`
(
`id`,
`null_one`,
`null_two`,
`null_three`,
`name`,
`Number`,
`expMonth`,
`Year`,
`CV`,
`address`,
`town`,
`state`,
`country`,
`zipCode`,
`email`
)
VALUES
(
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s'
);",
$id,
$null_one,
$null_two,
$null_three,
$name,
$Number,
$Month,
$Year,
$cv,
$address,
$town,
$state,
$country,
$zipCode,
$email
);

mysql_query($query) or die(mysql_error());


?>



There was a database connector in there but i took it out obviously for security :P

Also, I know this doesn't apply to coding standards in most places, and Its probably not the most efficient way of doing it, but it works ^^






THE PEOPLE UNITED WILL NEVER BE DEFEATED!

don't care for money, and money's not for me,
the money fueled this empire and our racist history.
Although I'm forced to use it, the rules have all been set.
But life is not worth living when yer soul is in debt!

MONEY KILLS.
MONEY RAPES.
MONEY LIES.
MONEY HATES.
Author

RE: [PHP] File Read/Upload Arrays to DB

DarkMantis
Member



Posts: 192
Location: Bringing Security To You!
Joined: 23.04.06
Rank:
Elite
Posted on 24-07-09 09:54
Yeah I thought that would be a big problem posting my problem here, I wasn't sure how to phrase it. Okay, well thanks for trying anyway.

Umm, I'll have a think on how to rephrase it better.

And sorry, I thought you meant just post it here:)




THE PEOPLE UNITED WILL NEVER BE DEFEATED!

don't care for money, and money's not for me,
the money fueled this empire and our racist history.
Although I'm forced to use it, the rules have all been set.
But life is not worth living when yer soul is in debt!

MONEY KILLS.
MONEY RAPES.
MONEY LIES.
MONEY HATES.
Author

RE: [PHP] File Read/Upload Arrays to DB

spyware
Member



Posts: 4190
Location: The Netherlands
Joined: 14.04.07
Rank:
God
Warn Level: 90
Posted on 24-07-09 09:56
serialze()
unserialize()




"The chowner of property." - Zeph
“Widespread intellectual and moral docility may be convenient for leaders in the short term,
but it is suicidal for nations in the long term.”
- Carl Sagan
“Since the grid is inescapable, what were the earlier lasers about? Does the corridor have a sense of humor?” - Ebert
http://bitsofspy.net
Guest
Username

Password

Remember Me


Bookmark This Page
Affiliates
Adverts

 

 

Links
By using, viewing or obtaining any information contained on this site, you agree to the disclaimer.

© HellBound Hackers 2008- 2009. Since 3rd December 2004.