Page 2 of 2

Posted: Fri Jun 20, 2003 10:35 am
by Keanman
The error still occurs. I'm almost 100% sure the includes have no connection to the problem. I believe that both of my problems lay somewhere in this statement:

Code: Select all

<A HREF=update.php?id=$rs['id'];>Edit</A>
Here is the whole code of updateForm.php:

Code: Select all

<?
include("header.inc");
include("details.inc");
?>

<H2>hoose a Record to Update</H2>
<A HREF="enterForm.php">Enter a Record</A>
 <A HREF="searchForm.php">Search Database</A>
 <A HREF="userForm.php">Create a New User</A><P><HR></CENTER><P>

<?

include("title.inc");

$query="SELECT * FROM assets ORDER BY location ASC";
$result=mysql_query($query);

while ($rs = mysql_fetch_array($result)) {

print ("<TR ALIGN=CENTER><TD><A HREF=update.php?id=$rs['id'];>Edit</A></TD><TD>" . $rs['itemName'] . "</TD><TD>" . $rs['serialNum'] . "</TD><TD>" . $rs['assetNum'] . "</TD><TD>" . $rs['location'] . "</TD><TD>" . $rs['description'] . "</TD><TD>" . $rs['entryDate'] . "</TD><TD>" . $rs['warranty'] . "</TD></TR>");
}

include("footer.inc");
?>

Posted: Fri Jun 20, 2003 10:43 am
by Keanman
Ok, the error is still occuring. I'm almost 100% sure that both of my problems are being caused by this statement:

Code: Select all

<A HREF=update.php?id=$rs['id'];>Edit</A>
Here is the whole code:

Code: Select all

<?
include("header.inc");
include("details.inc");
include("title.inc");

$query="SELECT * FROM assets ORDER BY location ASC";
$result=mysql_query($query);

while ($rs = mysql_fetch_array($result)) {

print ("<TR ALIGN=CENTER><TD><A HREF=update.php?id=$rs['id'];>Edit</A></TD><TD>" . $rs['itemName'] . "</TD><TD>" . $rs['serialNum'] . "</TD><TD>" . $rs['assetNum'] . "</TD><TD>" . $rs['location'] . "</TD><TD>" . $rs['description'] . "</TD><TD>" . $rs['entryDate'] . "</TD><TD>" . $rs['warranty'] . "</TD></TR>");
}

include("footer.inc");
?>

Posted: Fri Jun 20, 2003 11:32 am
by releasedj
Yeah you can't have array elements like that in a string. Just close and open the string again:

Code: Select all

print ("<TR ALIGN=CENTER><TD><A HREF="update.php?id=".$rs['id']."">Edit...

Posted: Fri Jun 20, 2003 11:38 am
by nielsene
Or wrap it in {} such as

Code: Select all

print("<tr align="center"><td><a href="update.php?id={$rs["id"]}">Edit....

Posted: Fri Jun 20, 2003 11:49 am
by releasedj
Personally, I don't believe in mixing variables within strings. I'd much rather concatenate as it makes it easier to understand in my opinion.

For that same reason I don't bother using double-quotes for string, therefore they won't get parsed by PHP.

Posted: Fri Jun 20, 2003 12:25 pm
by Keanman
I found out what the problem was after. I put a fetch in the update.php file and all was well. Thanks for all your help guys.