I'm having a hard time figuring out how to solve a problem I have with some code. I'm using an image button to submit an update to a database. A similar chunk of code successfully works to delete field elements. All I'm trying to do is update field elements the same way, but a little more complex. The problem has to be with how I've designed my mysql query. Either that or I've biffed it somewhere on syntax.
The errors reads like this:
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/shabangw/public_html/editProjLeads.php on line 8
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/shabangw/public_html/editProjLeads.php on line 9
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/shabangw/public_html/editProjLeads.php on line 13
The chunk of code below is called editProjLeads.php:
<?PHP
if($Edit_x){
$conn = db_connect();
//declare query
$query = 'SELECT id, companyName, contact, phoneNum, email, street, city, provState, country, postalCode, url, contractStatus FROM currProjects WHERE id="'.$ID.'"';
//execute Query
$result = mysql_query($query);
$jobid = mysql_query($result, 'id');
$Company = mysql_query($result, 'companyName');
$cont = mysql_result($result, 'contact');
$phone = mysql_result($result, 'phoneNum');
$Email = mysql_result($result, 'email');
$Street = mysql_query($result, 'street');
$City = mysql_result($result, 'city');
$Prov = mysql_result($result, 'provState');
$Country = mysql_result($result, 'country');
$postal = mysql_result($result, 'postalCode');
$URL = mysql_result($result, 'url');
$contStat = mysql_result($result, 'contractStatus');
mysql_close();
if($UpdateProjLeads) {
$conn = db_connect();
//declare query
$query = 'UPDATE currProjects SET companyName="'.$comp.'", contact="'.$Contact.'", phoneNum="'.$Phone.'", email="'.$E_mail.'", provState="'.$Prov.'", country="'.$Cntry.'", postalCode="'.$Postal.'", contractStatus="'.$contStat.'", street="'.$St.'", city="'.$CIty.'", url="'.$Url.'" WHERE id="'.$ID.'"';
//execute query
$result = mysql_query($query);
}
?>
<div id="editWin" class="drag">
<form action="<?php echo $PHP_SELF ?>" method="post" name="editProjLeads">
<input name="ID" type="hidden" value="<?PHP echo $jobid ?>">
<div align="center">Company Name:
<select name="comp">
<?PHP
$conn = db_connect();
//declare query
$query = 'SELECT companyName FROM currProjects';
//Execute Query
$result = mysql_query($query);
$x = 0;
while ($x < mysql_num_rows($result)) :
$company = mysql_result($result, $x, 'companyName');
print "<option value='$company' ";
if ($company==$Company) print "selected";
print">$company</option>";
$x++;
endwhile;
print "</select>";
mysql_close();
?>
Contact Name:
<input name="Contact" type="text" value="<?PHP echo $cont ?>">
<br>
<br>
Phone:
<input name="Phone" type="text" value="<?PHP echo $phone ?>">
E-mail:
<input name="E_mail" type="text" value="<?PHP echo $Email ?>">
<br>
<br>
Street:
<input name="St" type="text" value="<?PHP echo $Street ?>">
City:
<input name="CIty" type="text" value="<?PHP echo $City ?>">
<br>
<br>
State/Province:
<select name="Prov">
<option value="Alberta" <?PHP if($prov=="Alberta"){ echo("selected");}?> >Alberta</option>
<option value="British Columbia" <?PHP if($prov=="British Columbia"){ echo("selected");}?> >British Columbia</option>
<option value="Saskatchewan" <?PHP if($prov=="Saskatchewan"){ echo("selected");}?> >Saskatchewan</option>
<option value="Manitoba" <?PHP if($prov=="Manitoba"){ echo("selected");}?> >Manitoba</option>
<option value="Yukon" <?PHP if($prov=="Yukon"){ echo("selected");}?> >Yukon</option>
<option value="North West Territories" <?PHP if($prov=="North West Territories"){ echo("selected");}?> >North West Territories</option>
<option value="Nova Scotia" <?PHP if($prov=="Nova Scotia"){ echo("selected");}?> >Nova Scotia</option>
<option value="Ontario" <?PHP if($prov=="Ontario"){ echo("selected");}?> >Ontario</option>
<option value="Quebec" <?PHP if($prov=="Quebec"){ echo("selected");}?> >Quebec</option>
<option value="Newfoundland" <?PHP if($prov=="Newfoundland"){ echo("selected");}?> >Newfoundland</option>
<option value="Nunavut" <?PHP if($prov=="Nunavut"){ echo("selected");}?> >Nunavut</option>
<option value="Prince Edward Island" <?PHP if($prov=="Prince Edward Island"){ echo("selected");}?> >Prince Edward Island</option>
<option value="New Brunswick" <?PHP if($prov=="New Brunswick"){ echo("selected");}?> >New Brunswick</option>
</select>
Country:
<select name="Cntry">
<option value="Canada" <?PHP if($Country=="Canada"){ echo("selected");}?> >Canada</option>
<option value="United States" <?PHP if($Country=="United States"){ echo("selected");}?> >United States</option>
<option value="Ireland" <?PHP if($Country=="Ireland"){ echo("selected");}?> >Ireland</option>
</select>
<br>
<br>
Postal Code:
<input name="Postal" type="text" value="<?PHP echo $postal ?>">
URL:
<input type="text" name="Url" value="<?PHP echo $URL ?>">
<br>
<br>
Contract Status:
<select name="contStat">
<option value="active" <?PHP if($contStatus=="active"){ echo("selected");}?> >active</option>
<option value="none" <?PHP if($contStatus=="none"){ echo("selected");}?> >none</option>
<option value="expired" <?PHP if($contStatus=="expired"){ echo("selected");}?> >expired</option>
</select>
<br>
<br>
<br>
<input type="submit" name="UpdateProjLeads" value="Update">
<input type="reset" name="Submit2" value="Reset">
</div>
</form>
</div>
<?PHP } ?>
The main code which is called projLeads.php is attached as a text file. Convert the .txt to .php. If you can help me with the problem then hats off to you. My brain is going numb.