RE: [PHP] What am I doing wrong? [beginner]
| From: | David Buerer | Date: | Fri, 19 Jul 2002 15:04:56 +0000 |
| Subject: | RE: [PHP] What am I doing wrong? [beginner] | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-108529@lists.php.net to get a copy of this message | ||
Just for grins try this...
$query="SELECT name,x FROM controllpoints_tbl WHERE (process_nr=$process_nr)
AND (type=$typvar) ORDER BY x";
$result=mysql_query($query) or echo "Query failed!<br>$query";
Then run it and see what happens. My guess is that your query is failing and
that is the real cause of your problem. If the query fails, $result is not
valid and the while loop will surely fail.
David Buerer
Senior Designer
PLA Designs, Inc.
-----Original Message-----
From: Martin Johansson [mailto:d99majo@swipnet.se]
Sent: Friday, July 19, 2002 8:21 AM
To: php-general@lists.php.net
Subject: [PHP] What am I doing wrong? [beginner]
AHHHHHRGGG this is getting me on my nerves!!!##!!
I am using a mySQL-databasetable called controllpoints_tbl with the
following structure:
+----+------------+-----------+-----+------+-----+--------------------------
---------------------------+
| nr | process_nr | type | abb | name | x | description
|
+----+------------+-----------+-----+------+-----+--------------------------
---------------------------+
| 1 | 1 | Milestone | MS | MS1 | 200 | bla bla bla
|
| 2 | 1 | Milestone | MS | MS2 | 500 | bla bla bla
|
| 3 | 1 | Tollgate | TG | TG1 | 100 | bla bla
bla |
| 4 | 1 | Milestone | MS | MS4 | 600 | bla bla bla
|
+----+------------+-----------+-----+------+-----+--------------------------
---------------------------+
I want to view just the "name" and "x" variable with this code...
for ($i=1;$i<=$antal_typer;$i++)
{
$typvar = $type[$i]; // this is an array with types
$here = 150+17*$i;
echo "Hello";
$result = mysql_query("select name,x FROM controllpoints_tbl where
process_nr=$process_nr and type=$typvar order by x");
while ($myrow = mysql_fetch_row($result)) // this is line
138...
{
// here's a lot of code..
}
}
but it never enters the while loop.. and only print Hello one time although
$antal_typer = 2;
a warning message says:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result
resource in c:\inetpub\wwwroot\devproc\beta\view.php on line 138
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php