/    Sign up×
Community /Pin to ProfileBookmark

JPGraph acting weired

OK

trying to create a scatter graph by using JPGraph (example file sctterex1.php)

the graph is created from the values in the uploaded CSV file

I get the values from CSV file using this function

[code=php]

<?php
function read_csv_file($file_to_read){

# Open the File.
if (($handle = fopen($_FILES[$file_to_read][‘tmp_name’], “r”)) !== FALSE) {

# Set the parent multidimensional array key to 0.
$nn = 0;
while (($data = fgetcsv($handle, 1000, “,”)) !== FALSE) {
# Count the total keys in the row.
$c = count($data);
# Populate the multidimensional array.
for ($x=0;$x<$c;$x++)
{
$csvarray[$nn][$x] = $data[$x];
}
$nn++;
}
# Close the File.
fclose($handle);
}
# Print the contents of the multidimensional array.

return $csvarray;
}
?>

[/code]

which if kept in functions/read_csv_file.php

yet, when I run

[code=php]require_once (‘functions/read_csv_file.php’);[/code]

the graph returns an error

Here’s the code for the page as it is now

[code=php]
<?php // content=”text/plain; charset=utf-8″

// Some data for the points
$data = array();
//$datax = array();
//$datay = array();

switch (true){

case (isset($_FILES[‘csv’][‘tmp_name’])):

require_once (‘../jpgraph.php’);
require_once (‘../jpgraph_scatter.php’);
require_once (‘functions/read_csv_file.php’);
require_once (‘functions/create_scatter_plot.php’);

$data = read_csv_file(‘csv’);

$datax = array(3.5,3.7,3,4,6.2,6,3.5,8,14,8,11.1,13.7);
$datay = array(20,22,12,13,17,20,16,19,30,31,40,43);

//create_scatter_plot($datax, $datay);

break;

default:

echo’
<html>
<head>
<title>read uploaded csv file</title>
</head>

<body>

<form action=”scatter.php” method=”post” enctype=”multipart/form-data”>

<input name=”csv” id=”csv” type=”file”>

<input type=”submit” name=”send” id=”send” value=”Submit”/>

</form>

</body>

</html>
‘;

break;

}

?>

[/code]

any ideas

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @Nightcat spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...