Hi Guys,
I’m trying to do the following:
[ul][li]User inputs an ID in a search box[/li]
[li]Query goes off to the DB, finds the record[/li]
[li]Returned results are populated into fields in a form[/li]
[li]User edits the fields and submits the new values[/li]
[li]Submitting script updates the required table with the new values[/li][/ul]
Now, I haven’t completed my code fully as yet. However, I wanted to test out some stuff before continuing and now I’m getting an error and I’m not sure why. Basically, I’m checking if I can grab the required values before I build the form. But it’s not working. Here’s my code:
[php]
<? mysql_connect("localhost", "******", "******") or die(mysql_error()); mysql_select_db("******") or die(mysql_error()); //Register globals are set to off, so we need to get the following across $animalID = $_POST['animalID']; //Now we have connected, we're going to match the details that are entered into the Animal ID field $sql = "SELECT 'animalID', 'status', 'date', 'species', 'breed', 'sex', 'primary_colour', 'colour', 'distinctive_traits', 'fur_length', 'age', 'desexed', 'microchipped', 'suburb', 'pound_area', 'contact', 'link' FROM animal_info WHERE 'animalID' = '%$animalID%'"; $result = mysql_query ($sql) or die(mysql_error()); $query=getenv(QUERY_STRING); parse_str($query); ?>[/php]
<html>
<body>
<title>Edit an Animal</title>
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
</head>
<body>
<div id="art-page-background-glare-wrapper">
<div id="art-page-background-glare">
</div>
</div>
<div id="art-main">
<div class="cleared reset-box">
</div>
<div class="art-box art-sheet">
<div class="art-box-body art-sheet-body">
<div class="art-header">
<div class="art-headerobject">
</div>
<div class="art-logo">
<h1 class="art-logo-name">
<a href="index.php">Pets of Perth</a>
</h1>
<h2 class="art-logo-text">Lost and Found</h2></div>
</div>
<div class="cleared reset-box">
</div>
<div class="art-layout-wrapper">
<div class="art-content-layout">
<div class="art-content-layout-row">
<div class="art-layout-cell art-sidebar1">
<div class="art-box art-vmenublock">
<div class="art-box-body art-vmenublock-body">
<div class="art-bar art-vmenublockheader">
<h3 class="t">Main Menu</h3>
</div>
<div class="art-box art-vmenublockcontent">
<div class="art-box-body art-vmenublockcontent-body">
<ul class="art-vmenu">
<li>
<a href="index.php" class="">Welcome!</a>
</li>
<li><a href="add.php">Add an Animal</a></li>
<li> <a href="search.php">Search for an Animal</a>
<li> <a href="edit.php" class="active">Edit an Animal</a>
</li>
</ul>
</li>
</ul>
<div class="cleared"></div>
</div>
</div>
<div class="cleared">
</div>
</div>
</div>
<div class="cleared">
</div>
</div>
<div class="art-layout-cell art-content">
<div class="art-box art-post">
<div class="art-box-body art-post-body">
<div class="art-post-inner art-article">
<h2 class="art-postheader">Editing <?php echo $animalID;?></h2>
<div class="art-postcontent">
<br />
<br />
[php]
<?php while ($row = $sql->fetch_assoc()); echo $row['primary_colour']; ?>[/php]
<BR></p>
</div>
<div class="cleared">
</div>
</div>
<div class="cleared"></div>
</div>
</div>
<div class="cleared"></div>
</div>
</div>
</div>
</div>
<div class="cleared">
</div>
<div class="art-footer">
<div class="art-footer-body">
<a href="#" class="art-rss-tag-icon" title="RSS"></a>
<div class="art-footer-text">
<p>Copyright © 2012 Pets of Perth, Lost and Found. All Rights Reserved.</p>
<p>Website by <a href="#" target="_blank">Company Name</a>
</p>
</div>
<div class="cleared"></div>
</div>
</div>
<div class="cleared"></div>
</div>
</div>
<div class="cleared"></div>
<p class="art-page-footer"></p>
<div class="cleared"></div>
</div>
</body>
</html>
I’m getting the error:
Fatal error: Call to a member function fetch_assoc() on a non-object in home/loveani/public_html/poplaf/edit_process.php on line 93
Any help would be appreciated!
Cheers,
Dave