[php] Record updating problem
Hello,
Just having a problem updating a record - it worked on my old website but for some reason its not working now.
Its not firing any errors so im unsure whats wrong - knowing my luck ive missed a line of code out somewhere.
Any help will be greatly appreciated!
PHP Code:
<?php
mysql_connect("localhost","root","");
mysql_select_db("db1") or die( "Unable to select database");
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
if (!isset($_POST["submit"]))
{
$id = $_GET["id"];
$sql = "SELECT * FROM domains WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<h1>Make Domain Changes</h1>
<center>
<form method="post" action="edit.php">
<table width="450" border="0">
<input type=hidden name='id' value='<?php echo $myrow["id"] ?>'>
<input type=hidden name='username' value='<?php echo $myrow["username"] ?>'>
<tr>
<td>Domain Name:</td>
<td><INPUT TYPE='TEXT' NAME='domain_name' VALUE='<?php echo $myrow["domain_name"] ?>' SIZE=30></td>
</tr>
<tr>
<td>Compnay Name:</td>
<td><INPUT TYPE='TEXT' NAME='company_name' VALUE='<?php echo $myrow["company_name"] ?>' SIZE=30></td>
</tr>
<tr>
<td>Simply Account:</td>
<td><INPUT TYPE='TEXT' NAME='simply_account' VALUE='<?php echo $myrow["simply_account"] ?>' SIZE=30></td>
</tr>
<tr>
<td>Notes:</td>
<td><TEXTAREA NAME='notes' ROWS=5 COLS=30><? echo $myrow["notes"] ?></TEXTAREA></td>
</tr>
<tr>
<td>Expirey Date:</td>
<td><INPUT TYPE="TEXT" NAME='exp_date' VALUE='<?php echo $myrow["exp_date"] ?>' SIZE=30></td>
</tr>
<tr>
<td><div align='center'><input type='hidden' name='cmd' value='edit'>
<input type='submit' name='submit' value='submit'></div></td>
</tr>
</table>
</form></center>
<? } ?>
<?
if ($_POST["$submit"])
{
$domain_name = $_POST["domain_name"];
$company_name = $_POST["company_name"];
$simply_account = $_POST["simply_account"];
$notes = $_POST["notes"];
$exp_date = $_POST["exp_date"];
$sql = "UPDATE domains SET domain_name='$domain_name',company_name='$company_name',simply_account='$simply_account',notes='$notes',exp_date='$exp_date' WHERE id=$id AND username = '$session->username'";
$result = mysql_query($sql);
echo "$domain_name has been updated :-)";
}
}
?>
Re: [php] Record updating problem
Maybe you need to use <?php ?> instead of <? ?>
And, why did you ever wrote this:
$_POST["$submit"]
Rediculous, I already try not to ever use variables between quotes, and use single-quotes where I can. It's faster and much more clear to what happens.
Your server probably has different settings, and therefore does not support some of these features. Check every input and output carefully, and check if you actually filled the tables on the new server.
Re: [php] Record updating problem
Made the changes - but still doesnt update - currently its hosted locally on my machine to make swift changes without ftp - but ill set it up on my hosting to see if its any differnet.
Ta Daevius
edit: Set my script up on my hosting - still the same - :x