Page 1 of 2
array echo
Posted: Thu Nov 10, 2005 1:34 am
by joecrack
i made this script that has to print out an array
i know the SELECT looks strage .. but i tried it in phpmyadmin and its working.
so insted of the array i get this!
Parse error: parse error, unexpected $ in C:\Server\xampp\htdocs\inword.php on line 15
Code: Select all
<?php
$db = @mysql_connect('localhost','root','') OR die(mysql_error());
@mysql_select_db(safe,$db) OR die(mysql_error());
$sql ="SELECT sam_bestellung.customernr,sam_bestellung.hull,sam_bestellung.custrefnr,sam_bestellung.custrefname,
sam_date_val.incdate FROM sam_bestellung,sam_date_val WHERE sam_bestellung.projnr='159' AND sam_date_val.projnr='159' AND sam_bestellung.customernr='02.01.' AND sam_date_val.customernr='02.01.'";
$result = mysql_query($sql);
$zeile = mysql_fetch_array($result);
echo "{$zeile['customernr']} - {$zeile['hull']} - {$zeile['custrefname']} - {$zeile['incdate']}</p>';
mysql_close();
?>
Posted: Thu Nov 10, 2005 1:44 am
by jmut
Well, as a start you might try removing these @
turn on displaying errors...and switching on error_reporting(E_ALL).
Because the problem might be somewhere else...
Posted: Thu Nov 10, 2005 2:02 am
by joecrack
display errors are on - error_reporting(E_ALL) is on - @ are gone!!!
still same output
Posted: Thu Nov 10, 2005 2:42 am
by shiznatix
Code: Select all
<?php
$db = @mysql_connect('localhost','root','') OR die(mysql_error());
@mysql_select_db(safe,$db) OR die(mysql_error());
$sql ="SELECT sam_bestellung.customernr,sam_bestellung.hull,sam_bestellung.custrefnr,sam_bestellung.custrefname,
sam_date_val.incdate FROM sam_bestellung,sam_date_val WHERE sam_bestellung.projnr='159' AND sam_date_val.projnr='159' AND sam_bestellung.customernr='02.01.' AND sam_date_val.customernr='02.01.'";
$result = mysql_query($sql);
$zeile = mysql_fetch_array($result);
echo $zeile['customernr'].' - '.$zeile['hull'].' - '.$zeile['custrefname'].' - '.$zeile['incdate'].'</p>';
mysql_close();
?>
Posted: Thu Nov 10, 2005 3:06 am
by joecrack
Now its like this:
Code: Select all
<?php
error_reporting(E_ALL);
$db = mysql_connect('localhost','root','') OR die(mysql_error());
mysql_select_db(safe,$db) OR die(mysql_error());
$sql ="SELECT sam_bestellung.customernr,sam_bestellung.hull,sam_bestellung.custrefnr,sam_bestellung.custrefname,sam_date_val.incdate FROM sam_bestellung,sam_date_val WHERE sam_bestellung.projnr='159' AND sam_date_val.projnr='159' AND sam_bestellung.customernr='02.01.' AND sam_date_val.customernr='02.01.'";
$result = mysql_query($sql);
$zeile = mysql_fetch_array($result);
echo $zeile['customernr'].' - .'$zeile['hull'].' - '.$zeile['custrefname'].' - '.$zeile['incdate'].'</p>;
mysql_close();
?>
Still i get a damn ParseError:
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in C:\Server\xampp\htdocs\inword.php on line 13
Posted: Thu Nov 10, 2005 3:21 am
by n00b Saibot
].'</p>; should be ].'</p>';
Posted: Thu Nov 10, 2005 3:41 am
by Jenk
Do you actually read the errors?

Posted: Thu Nov 10, 2005 3:52 am
by n00b Saibot
Jenk wrote:Do you actually read the errors?
why? does there seem any doubt
@joecrack:
Code: Select all
echo $zeile['customernr'].' - .'$zeile['hull'].' - '.$zeile['custrefname'].' - '.$zeile['incdate'].'</p>;
should be
Code: Select all
echo $zeile['customernr'].' - '.$zeile['hull'].' - '.$zeile['custrefname'].' - '.$zeile['incdate'].'</p>';
Posted: Thu Nov 10, 2005 4:19 am
by Jenk
n00b Saibot wrote:Jenk wrote:Do you actually read the errors?
why? does there seem any doubt
That was pointed at joecrack, not you

Posted: Thu Nov 10, 2005 7:01 pm
by joecrack
Okey nice nor i have the array printout.
So - my next question now i would like to know how i can print the array in different parts of a html document.
I can write like this:
$zeile['customernr'].' xyzxyzxyz blah blah </br> '.$zeile['hull'].' -
and its still working, but as soon as I do it like this:
echo Hello </br> $zeile['customernr'].' xyzxyzxyz blah blah </br> '.$zeile['hull'].
it is not working any more.
how can i solve this problem?
Posted: Thu Nov 10, 2005 7:56 pm
by shiznatix
PLEASE! USE PHP TAGS WHEN POSTING CODE! you will easily find your solution. you just have to put quotes around the html/non php stuff then put a period in between the quotes where you want to echo out the php variables.
Posted: Thu Nov 10, 2005 8:20 pm
by joecrack

Praise Lord shiznatix

thx a lot =)
Posted: Thu Nov 10, 2005 9:32 pm
by joecrack
hi
but this just works if there are just some words and hml tags in between the array output.
because i tried to enter a hole html page (with many quotes and dots andsoon) and its not showing anything but parse errors.
the thing is i have to make a scipt that automaticly prints out a order confirmation for the customer and insert the array output in some parts.
If i do it like this:
Code: Select all
echo "<html><h1>sdfdsf</h1></br></br>".$zeile['yardcust']."sdfsdfds</br>".$zeile['hull'].' - '.$zeile['fax'].' - '.$zeile['incdate'].'</p>';
Its no problem.
But as soon as i want to add <style type="text/css">... </style> its not working.
I think this is just not the right way to solve the problem.
please HELP
Posted: Fri Nov 11, 2005 12:38 am
by s.dot
you're going to need to escape the quotes in your HTML (they're conflicting with echo ""s quotes)
instead of
Posted: Fri Nov 11, 2005 12:47 am
by mickd
if your php editor program doesnt have syntax highlighting i suggest to download and use one that does (lots mentioned in the general section in 1 of the stickys)
it helps because if you forget a ' or " or forget to close a " or ', the colour goes weird and makes it extremely easy to notice.