Parse error: syntax error, unexpected T_SL in C:\AppServ\www\graphtest.php on line 15

$sql = <<<EOS   this have problem......but what is it?
also $conn->Connect('localhost', 'root', '1234567', 'zend');

'zend ' what is this filed i should input?
i use Jpgraph ~ php4
thanks
<?php 
 
require_once('jpgraph/jpgraph.php'); 
require_once('jpgraph/jpgraph_bar.php'); 
require_once('jpgraph/jpgraph_line.php'); 
 
 
if (USE_DB) { 
    // establish a connect to the database 
    $conn = &ADONewConnection('mysql'); 
    $conn->Connect('localhost', 'root', '1234567', 'zend'); 
    $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; 
 
    // make an sql statement to retrieve the data you want 
   $sql = <<<EOS 
    SELECT dt, 
        MONTHNAME(dt) AS mon, 
        plan, 
        actual, 
        forecast 
    FROM data 
    WHERE dt >= '2002-01-01' 
        AND dt < '2003-01-01' 
    ORDER BY dt ASC 
EOS; 
 
    // create a result set by executing your sql over the connection 
    $rs = $conn->Execute(trim($sql)); 
 
    // iterate over the result set and create $data arrays 
    while ($rs && !$rs->EOF) { 
        $row = $rs->fields; 
        $labelx[] = substr($row['mon'],0,3); 
        $data['plan'][] = $row['plan']; 
        $data['actual'][] = $row['actual']; 
        $data['forecast'][] = $row['forecast']; 
        $rs->MoveNext(); 
    } 
} else { // USE_DB false 
    $data['plan'] = array (  
            11.5, 12, 12, 13.5, 10, 9.5,  
            11, 12, 12, 11, 13, 12.5 ); 
    $data['actual'] = array(  
            12, 14, 14.5, 13, 9, 4,  
            0, 0, 0, 0, 0, 0 ); 
    $data['forecast'] = array (  
            0, 0, 0, 0, 0, 10,  
            12, 14, 13, 10, 11, 13 ); 
    for($i = 0; $i < count($data['actual']); $i++) { 
        $labelx[] = strftime('%b',  
                mktime(0, 0, 0, $i+1, 1, date('Y'))); 
    } 
} 
 
// create the "good" and "bad" series for our red/green look 
for($i = 0; $i < count($data['actual']); $i++) { 
    if ($data['actual'][$i] >= $data['plan'][$i]  
        || $data['forecast'][$i] >= $data['plan'][$i]) { 
        $data['good'][$i] = $data['actual'][$i]; 
        $data['bad'][$i] = 0; 
    } else { 
        $data['good'][$i] = 0; 
        $data['bad'][$i] = $data['actual'][$i]; 
    } 
} 
 
// set title and name for the chart 
$title = date('Y').' Plan vs Actual & Forecast'; 
$graph_name = 'chart.png'; 
 
/** 
* JpGraph - Step 1 
* Create the graph object and set general parameters 
*/ 
 
// set general graph details 
$graph = new graph(450, 300, $graph_name, 0, false); 
 
//    margins, background color, scale and shadow for the whole graph 
$graph->img->SetMargin(50, 30, 30, 80); 
$graph->SetMarginColor('white'); 
$graph->SetScale('textlin'); 
$graph->SetShadow(); 
 
//    set the title and font 
$graph->title->Set($title); 
$graph->title->SetFont(FF_VERDANA, FS_BOLD, 14); 
 
//    set the y-axis and title it 
$graph->yaxis->SetLabelAngle(0); 
$graph->yaxis->title->Set('Units in Thousands'); 
$graph->yaxis->title->SetFont(FF_FONT1, FS_BOLD); 
 
//    set the x-axis, labels and title it 
$graph->xaxis->SetLabelAngle(0); 
$graph->xaxis->SetFont(FF_VERDANA, FS_NORMAL, 8); 
$graph->xaxis->SetTickLabels($labelx); 
 
//    set the graph title and font 
$graph->xaxis->title->Set('Month'); 
$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD); 
 
/** 
* JpGraph - Step 2 
* Set the individual plot details 
*/ 
 
// line1 is the plan data line, green, thick and marked with circles 
$line1 = new LinePlot($data['plan']); 
$line1->mark->SetType(MARK_CIRCLE); 
$line1->SetColor('darkolivegreen'); 
$line1->SetWeight(3); 
$line1->SetCenter(); 
$line1->SetLegend('Plan'); 
 
// bar1 is the green bars for actual or forecast above plan 
$bar1 = new BarPlot($data['good']); 
$bar1->SetFillColor('green'); 
$bar1->SetAlign('center'); 
$bar1->SetWidth(0.75); 
$bar1->SetLegend('Actual above Plan'); 
 
// bar2 is the red bars for actual and forecast below plan 
$bar2 = new BarPlot($data['bad']); 
$bar2->SetFillColor('red'); 
$bar2->SetAlign('center'); 
$bar2->SetWidth(0.75); 
$bar2->SetLegend('Actual below Plan'); 
 
// bar3 is the gray bars for forecast data 
$bar3 = new BarPlot($data['forecast']); 
$bar3->SetFillColor('silver'); 
$bar3->SetAlign('center'); 
$bar3->SetWidth(0.75); 
$bar3->SetLegend('Forecast'); 
 
/** 
* JpGraph - Step 3 
* Finalize and output the graph 
*/ 
 
// set legend details 
$graph->legend->SetLayout(LEGEND_HOR); 
$graph->legend->Pos(0.52, 0.85, 'center'); 
 
// add the graphs bottom to top 
$graph->Add($bar3); 
$graph->Add($bar2); 
$graph->Add($bar1); 
$graph->Add($line1); 
 
// output the graph to cache 
$graph->Stroke(); 
 
$page_title = 'Zend Graphing Tutorial'; 
 
/*    another example not covered in the tutorial, 
    output the data series values 
    into a table below the graph 
*/ 
for($i = 0; $i < count($data['actual']); $i++) { 
    $row_head .= '<th>'.$labelx[$i].'</th>'; 
    $row_plan .= '<td>'.number_format($data['plan'][$i], 1).'</td>'; 
    $row_act  .= '<td>'.number_format($data['actual'][$i], 1).'</td>'; 
    $row_fcst .= '<td>'.number_format($data['forecast'][$i], 1).'</td>'; 
} 
 
print <<<EOS 
<html> 
<head> 
<title>$page_title</title> 
</head> 
<body> 
<div style="text-align: center"> 
<h3>$page_title</h3> 
<img src="{$jpgcache}{$graph_name}" /> 
<p /> 
<table border="1" cellpadding="5" cellspacing="0"> 
<tr align="center"><th>Data</th>$row_head</tr> 
<tr align="right"><td><b>Plan</b></td>$row_plan</tr> 
<tr align="right"><td><b>Actual</b></td>$row_act</tr> 
<tr align="right"><td><b>Forecast</b></td>$row_fcst</tr> 
</table> 
</div> 
</body> 
</html> 
EOS; 
 
?>

Open in new window

ftpphptest1Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
agamalConnect With a Mentor Commented:
also i tried the attached code and i got

Invalid query: No database selected

mysql_connect('localhost','root','root','test') or die('Could not connect: ' . mysql_error());
$res = mysql_query('select * from users') or die('Invalid query: ' . mysql_error());

Open in new window

0
 
Ionut A. TudorPHP ProgrammerCommented:
for your first question it is a heredoc syntax EOF not EOS
$sql = <<<EOF
    SELECT dt,
        MONTHNAME(dt) AS mon,
        plan,
        actual,
        forecast
    FROM data
    WHERE dt >= '2002-01-01'
        AND dt < '2003-01-01'
    ORDER BY dt ASC
EOF;
this is the correct use, with any spaces after EOF
For your second question `zend` is your database name.
Hope this helps
0
 
Terry WoodsIT GuruCommented:
The error is caused by the space character after the EOS on this line:

   $sql = <<<EOS 

Open in new window

0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
agamalCommented:
i belive the guys here have answered your first Q ... but i have a comment on the second Q

the zend value here called new_link
"If a second call is made to mysql_connect()        with the same arguments, no new link will be established, but        instead, the link identifier of the already opened link will be        returned. The new_link  parameter modifies this         behavior and makes mysql_connect() always open         a new link, even if mysql_connect() was called         before with the same parameters.        In SQL safe mode, this parameter is ignored.       "

http://www.php.net/mysql_connect

unless your connect function has different structure
0
 
ftpphptest1Author Commented:
what is the meaning ?
as i find that there many sytax error...
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
0
 
agamalCommented:
we need to see the function connect() code
0
 
ftpphptest1Author Commented:
do u have any other example showing data in MySQL to the line chart ?

differnet element vs time line chart
thanks
 
0
 
agamalCommented:
if you want to make graph   ... there is a lot of tools to make graphs ... but the important thing to prepare the data in format to be ready to be plotted
0
 
ftpphptest1Author Commented:
o ic~~~so i need some example to show how to link php with mySQL to show data in chart
0
 
Ionut A. TudorPHP ProgrammerCommented:
You can open new question for that, i think this question with that error T_SL has been solved. Thanks
0
All Courses

From novice to tech pro — start learning today.