Page 1 of 2
just a simple array !!!
Posted: Thu Nov 03, 2005 6:36 pm
by joecrack
THIS SIMPLE #$%^&* does not work.
Code: Select all
<html><head>
<title>Datensatz löschen</title>
</head>
<body>
<?php;
error_reporting(E_ALL);
$db = mysql_connect("localhost","root","") or die ("MySQL-Fehler: " . mysql_error());
mysql_select_db("safe",$db) or die ("MySQL-Fehler: " . mysql_error());
$sql = "SELECT * FROM sam_artikel";
$result=mysql_query($sql);
$zeile=mysql_fetch_array($result);
echo "<p>{$zeile['eqdes']} - {$zeile['designer']} - {$zeile['value']} - {$zeile['beschreibung']} - {$zeile['eqdesignation']}</p>";
mysql_close();
?>
</body></html>
PLZ HELP
Posted: Thu Nov 03, 2005 6:39 pm
by Luke
error code?
Posted: Thu Nov 03, 2005 6:40 pm
by John Cartwright
One armed space goat wrote:error code?
furthurmore.. change
to
Code: Select all
$result=mysql_query($sql) or die(mysql_error());
Posted: Thu Nov 03, 2005 7:48 pm
by joecrack
There is nothing just a blank page.
Also if i write
$result=mysql_query($sql) or die(mysql_error());
like you said - NOTHING
joe
Posted: Thu Nov 03, 2005 8:16 pm
by feyd
check what $zeile actually is:
if you see anything other than an array definition, your query contained no results.
Posted: Thu Nov 03, 2005 8:33 pm
by John Cartwright
Are you sure you have display errors on?
Posted: Thu Nov 03, 2005 9:14 pm
by joecrack
Hai
i have display errors ON, i looked in the php.ini and also (i have xampp) the is a phpinfo page - also ON.
But i tried the script once with a wrong db name and no error appears !?!
Perhaps its display_startup_errors (i dont know what it is) its turned off !
I changed the code like this:
Code: Select all
<html><head>
<title>Datensatz löschen</title></head>
<body>
<?php;
error_reporting(E_ALL);
$db = mysql_connect("localhost","root","") or die ("MySQL-Fehler: " . mysql_error());
mysql_select_db("safe",$db) or die ("MySQL-Fehler: " . mysql_error());
$sql = "SELECT * FROM sam_artikel";
$result=mysql_query($sql) or die(mysql_error());
$zeile=mysql_fetch_array($result);
var_export($zeile);
echo "{$zeile['eqdes']} - {$zeile['designer']} - {$zeile['value']} - {$zeile['beschreibung']} - {$zeile['eqdesignation']}";
mysql_close();
?>
</body></html>
Also with the var_export ... NOTHING again just a blank site.
I dont know what the hell is going on.
joe
Posted: Thu Nov 03, 2005 10:43 pm
by John Cartwright
Check your PHP error logs.. from what I can tell it is a parse error. Also, double check when viewing the page that NO source code is displaying.[/list]
Posted: Thu Nov 03, 2005 11:13 pm
by joecrack
Theres nothing new in the error log ... just some errors 1 day old/.
THere realy is nothing i checked it a hundret times!!!
Posted: Thu Nov 03, 2005 11:22 pm
by TJ
How about adding a check on how many records have been returned from the query, so you know there 's something to print?
Code: Select all
$db = mysql_connect("localhost","root","") or die ("MySQL-Fehler: " . mysql_error());
mysql_select_db("safe",$db) or die ("MySQL-Fehler: " . mysql_error());
$sql = "SELECT * FROM sam_artikel";
$result=mysql_query($sql);
echo 'Rows returned: '. mysql_num_rows($result); // check for results
$zeile=mysql_fetch_array($result);
echo "<p>{$zeile['eqdes']} - {$zeile['designer']} - {$zeile['value']} - {$zeile['beschreibung']} - {$zeile['eqdesignation']}</p>";
mysql_close();
Posted: Fri Nov 04, 2005 1:17 am
by joecrack
NOTHING
when i insert:
echo 'Rows returned: '. mysql_num_rows($result);
still a blank page.
and its not like my php does not work.
other skips are working!!!
Posted: Fri Nov 04, 2005 1:23 am
by Jenk
Posted: Fri Nov 04, 2005 2:31 am
by joecrack
At least its printing out something:
Code: Select all
$zeile=mysql_fetch_array($result);
But still not working!!?
Posted: Fri Nov 04, 2005 3:04 am
by s.dot
print_r($zeile);
or, try the mysql_error() from $result
Posted: Sun Nov 06, 2005 6:57 pm
by joecrack
Finally OMG
its really printing out the first dataset.
This is the script right now:
Code: Select all
<?php
error_reporting(E_ALL);
$db = mysql_connect("localhost","root","") or die ("MySQL-Fehler: " . mysql_error());
mysql_select_db("safe",$db) or die ("MySQL-Fehler: " . mysql_error());
$sql = "SELECT * FROM sam_artikel" or die ("MySQL-Fehler: " . mysql_error());
$result=mysql_query($sql) or die(mysql_error());
$zeile=mysql_fetch_array($result);
echo "{$zeile['eqdes']} - {$zeile['designer']} - {$zeile['value']} - {$zeile['beschreibung']} - {$zeile['eqdesignation']}";
mysql_close();
?>
But now i would like it to print out all the datasets nut just the first one!
can i do that with:
$rows=mysql_num_rows($query); and than i print all rows out with WHILE... ???