migz Posted July 15, 2008 Share Posted July 15, 2008 Hi, I am a slight newbie at php-mysql scripting but I really feel I am doing this piece of scripting correctly. Basically I get a variable $publsher using GET like this: $publsher = $_GET['project']; And then have an if (isset($_POST['Submit'])) { //blah blah blah...here is the query causing the problem: $query="UPDATE publishers SET City = '$city' WHERE Companyname='".$publsher."'"; mysql_query($query) or die(mysql_error()); where $city is received from the page's form via a $_POST. Now it runs fine, but the database is not being updated. I have tried several different fields and methods to the update syntax, but it just won't update. And when I directly run the update on the phpmyadmin....it works. What I have figured is that the $publsher variable is not getting through.....and low and behold if(isset($publsher)){ $query="UPDATE publishers SET City = '$city' WHERE Companyname='".$publsher."'"; mysql_query($query) or die(mysql_error()); } else{ echo "there was a problem"; } It always goes to there was a problem. So the $publsher variable is somehow not being being red after the isset($_POST['Submit'])....any ideas??? Quote Link to comment https://forums.phpfreaks.com/topic/114937-solved-get-variable-problems/ Share on other sites More sharing options...
MadTechie Posted July 15, 2008 Share Posted July 15, 2008 can you please post the form Quote Link to comment https://forums.phpfreaks.com/topic/114937-solved-get-variable-problems/#findComment-591138 Share on other sites More sharing options...
migz Posted July 16, 2008 Author Share Posted July 16, 2008 No Problem, <form action="editpublisher.php" method="post"> <table width="100%" border="0" cellspacing="2" cellpadding="1"> <tr width = "100%" bgcolor="#1589FF" style="font-size: 23px;"><td><b>Edit Publisher</b></td></tr> <tr><td>Company Name: <input type="text" name="companyname" value="<? echo $row['Companyname']; ?>" maxlength="30" size="30" class="required" style="position: absolute; left:120px;"/></td></tr> <tr><td>Contact Person: <input type="text" name="contactperson" value="<? echo $row['Contactperson']; ?>" maxlength="50" class="required" style="position: absolute; left:120px;" size="30"/></td></tr> <tr><td>Street Address: <input type="text" name="streetaddress" value="<? echo $row['Streetaddress']; ?>" maxlength="50" class="required" style="position: absolute; left:120px;" size="30"/></td></tr> <tr><td>City: <input type="text" size="30" name="city" value="<? echo $row['City']; ?>" maxlength="55" class="required" style="position: absolute; left:120px;"/></td></tr> <tr><td>State: <input type="text" name="state" value="<? echo $row['State']; ?>" maxlength="30" class="required" style="position: absolute; left:120px;" size="30"/></td></tr> <tr><td>Zip: <input type="text" name="zip" value="<? echo $row['Zip']; ?>" maxlength="7" style="position: absolute; left:120px;" class="required validate-integer" size="30"/></td></tr> <tr><td>Phone1: <input type="text" name="phone1" value="<? echo $row['Phone1']; ?>" style="position: absolute; left:120px;" maxlength="14" class="required" size="30"/></td></tr> <tr><td>Phone2: <input type="text" name="phone2" value="<? echo $row['Phone2']; ?>" style="position: absolute; left:120px;" maxlength="14" size="30"/></td></tr> <tr><td>User name: <input type="text" name="username" value="<? echo $row['Username']; ?>" maxlength="30" style="position: absolute; left:120px;" class="required" size="30"/></td></tr> <tr style="position: absolute;"><td>Access Granted?:</td> <td class="radiop"><input type="radio" name="Yes"/>Yes</td><td class="radiop2"><input type="radio" name="No"/>No</td></tr> <tr style="position: absolute; top:300px;"><td><input type="submit" name="Submit"/></td></tr> </table> </form> Quote Link to comment https://forums.phpfreaks.com/topic/114937-solved-get-variable-problems/#findComment-591151 Share on other sites More sharing options...
migz Posted July 16, 2008 Author Share Posted July 16, 2008 Here is the rest to help you out. $query2 = "SELECT * FROM publishers where Companyname='$publsher'"; $result=mysql_query($query2) or die (mysql_error()); $row=mysql_fetch_array($result); if (isset($_POST['Submit'])) { $companyname=$_POST['companyname']; $contactperson=$_POST['contactperson']; $streetaddress=$_POST['streetaddress']; $city=$_POST['city']; $state=$_POST['state']; $zip=$_POST['zip']; $phone1=$_POST['phone1']; $phone2=$_POST['phone2']; $email=$_POST['email']; $username=$_POST['username']; $passwordHash = md5($_POST['email']); if(isset($_POST['Yes'])){ $grant=1; } else{ $grant=0; } $publsher = $publisher; if(isset($publsher)){ $query="UPDATE publishers SET City = '$city' WHERE Companyname='".$publsher."'"; mysql_query($query) or die(mysql_error()); mysql_query("UPDATE publishers SET Contactperson='$contactperson' WHERE Companyname='$publsher'") or die(mysql_error()); mysql_query("UPDATE publishers SET Streetaddress='$streetaddress' WHERE Companyname='$publsher'") or die(mysql_error()); mysql_query("UPDATE publishers SET State='$state' WHERE Companyname='$publsher'") or die(mysql_error()); mysql_query("UPDATE publishers SET Zip='$zip' WHERE Companyname='$publsher'") or die(mysql_error()); mysql_query("UPDATE publishers SET Phone1='$phone1' WHERE Companyname='$publsher'") or die(mysql_error()); mysql_query("UPDATE publishers SET Phone2='$phone2' WHERE Companyname='$publsher'") or die(mysql_error()); mysql_query("UPDATE publishers SET Username='$username' WHERE Companyname='$publsher'") or die(mysql_error()); mysql_query("UPDATE publishers SET Assess='$grant' WHERE Companyname='$publsher'") or die(mysql_error()); header("Location: complete.php?id=editpublisher"); } Quote Link to comment https://forums.phpfreaks.com/topic/114937-solved-get-variable-problems/#findComment-591154 Share on other sites More sharing options...
MadTechie Posted July 16, 2008 Share Posted July 16, 2008 change $publsher = $publisher; to $publsher = $companyname; Quote Link to comment https://forums.phpfreaks.com/topic/114937-solved-get-variable-problems/#findComment-591164 Share on other sites More sharing options...
migz Posted July 16, 2008 Author Share Posted July 16, 2008 *slaps head* Duh....wow......thanks a lot. I really really appreciate it. Quote Link to comment https://forums.phpfreaks.com/topic/114937-solved-get-variable-problems/#findComment-591170 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.