0

cant figure out why i'm getting this error:

Warning: implode() [function.implode]: Invalid arguments passed in C:\Users\Travis\Documents\choicegrid\dam_spp.php on line 67

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php
require_once('dom/simple_html_dom.php');

$url = "http://www.ercot.com/content/cdr/html/";  // The simple url
$name = "_dam_spp.html";                        // The parameter name
$date = date("Ymd");
//$date = date("Ymd",time()+60*60*24);       // The parameter value
$newUrl = $url . "$date$name";        // appending the values

//echo $newUrl;

	$html = file_get_html ($newUrl);

	// get the table. Maybe there's just one, in which case just 'table' will do
// Displays Extra Debug Info
$dbg = 1;
 
// Read DOM

 
// get the table. Maybe there's just one, in which case just 'table' will do
//$table = $html->find('#theTable');
 
// initialize empty array to store the data array from each row
$theData = array();


 
// loop over rows
foreach ($html->find('table') as $table) {
}

foreach($table->find('tr') as $row) {
 
// initialize array to store the cell data from each row
$rowData = array();
foreach($row->find('td') as $cell) {
 
// push the cell's text to the array
$rowData[] = $cell->plaintext;
}
 
// push the row's data array to the 'big' array
$theData[] = $rowData;
 unset($theData[0]);


 

}

foreach ($theData as $rows => $newData) {
	echo "<b>$rows</b><br>";
	foreach ($newData as $key => $value){
	
	
	echo "$key - $value<br>";
	
  $astring = implode("', '", $value);
$astringTwo = "'".$astring."'";
 echo "astringTwo <br>";
 }
}
3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by tgr0ss83
0

'your', 'string', 'should', 'appear', 'like', 'this'

right?

your first arg in implode should be implode('\', \'', $value);

0

string implode ( string $glue , array $pieces )
string implode ( array $pieces )

from PHP Manual

<?php

$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);

echo $comma_separated; // lastname,email,phone

// Empty string when using an empty array:
var_dump(implode('hello', array())); // string(0) ""

?>
0

Thanks, I was able to actually solve it with a For Statement.

for($i=0;$i<count($theData);$i++)
{
	 trim($theData[$i][1]);
$rs=$theData[$i];
$comma_separated = implode("','", $rs);

$username="xxx";
$password="xxx";
$database="xxx";
mysql_connect('127.0.0.1',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$astringTwo = "'".$comma_separated."'";


mysql_query("replace into dam_spp VALUES('$rs[1]',".$astringTwo.") ");

Thank you for your help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.