This is a form which members fill inside the members area:
The above form submits to the following script which is where the problem is:PHP Code:<?
session_start();
if (!isset($_SESSION['username'])) {
die('An error has ocurred. You have not logged in, or your session has expired.');
exit();
}
$dbcnx = @mysql_connect("localhost", "user", "pass");
if (!$dbcnx) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
// Select the database
if (! @mysql_select_db("needforcash_com") ) {
echo( "<p>Unable to locate the " .
"database at this time.</p >" );
exit();
}
$itis = "yes";
$itisnot = "no";
$sql = mysql_query("SELECT * FROM users WHERE username='$username'");
$lookup = mysql_fetch_assoc($sql);
$tacticsnow = $lookup['tacticsusername'];
$tacticsupdated = $lookup['tacticsupdated'];
$allmylistnow = $lookup['allmylistusername'];
$allmylistupdated = $lookup['allmylistupdated'];
$bwlnow = $lookup['bwlusername'];
$bwlupdated = $lookup['bwlupdated'];
$hercunow = $lookup['hercuusername'];
$hercuupdated = $lookup['hercuupdated'];
$promoneynow = $lookup['promoneyusername'];
$promoneyupdated = $lookup['promoneyupdated'];
$safelisternow = $lookup['safelisterusername'];
$safelisterupdated = $lookup['safelisterupdated'];
$hisreferer = $lookup['referer'];
$sqltwo = mysql_query("SELECT * FROM users WHERE username='$hisreferer'");
$reflookup = mysql_fetch_assoc($sqltwo);
$tacticslink = $reflookup['tacticsusername'];
$allmylistlink = $reflookup['allmylistusername'];
$bwllink = $reflookup['bwlusername'];
$herculink = $reflookup['hercuusername'];
$promoneylink = $reflookup['promoneyusername'];
$safelisterlink = $reflookup['safelisterusername'];
?>
<html>
.....
<form name="updatesafelists" method="post" action="updatesafelists.php">
<table width="100%" border="0" cellpadding="1" cellspacing="3">
<tr><td><b>Ad Tactics</b></td></tr>
<tr><td><a href="http://www.adtactics.com/index.php?ac=<?=$tacticslink?>">Click here to join</a></td></tr>
<tr><td>Enter your AdTactics username below<br>
<? if ($tacticsupdated == $itisnot) { ?>
http://www.adtactics.com/index.php?ac=<input name="tacticsnewlink" type="text"></td></tr>
<? } elseif ($tacticsupdated == $itis) { ?>
http://www.adtactics.com/index.php?ac=<input name="tacticsnewlink" type="text" value="<?=$tacticsnow?>"></td></tr>
<? } ?>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr><td><b>AllMyList</b></td></tr>
<tr><td><a href="http://www.allmylist.net/?refid=<?=$allmylistlink?>">Click here to join</a></td></tr>
<tr><td>Enter your AllMyList ID NUMBER below<br>
<? if ($allmylistupdated == $itisnot) { ?>
http://www.allmylist.net/?refid=<input name="allmylistnewlink" type="text"></td></tr>
<? } elseif ($allmylistupdated == $itis) { ?>
http://www.allmylist.net/?refid=<input name="allmylistnewlink" type="text" value="<?=$allmylistnow?>"></td></tr>
<? } ?>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr><td><b>Business World List</b></td></tr>
<tr><td><a href="http://businessworldlist.com/members/index.cgi?<?=$bwllink?>">Click here to join</a></td></tr>
<tr><td>Enter your Business World List username below<br>
<? if ($bwlupdated == $itisnot) { ?>
http://www.businessworldlist.com/members/index.cgi?<input name="bwlnewlink" type="text"></td></tr>
<? } elseif ($bwlupdated == $itis) { ?>
http://www.businessworldlist.com/members/index.cgi?<input name="bwlnewlink" type="text" value="<?=$bwlnow?>"></td></tr>
<? } ?>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr><td><b>HercuList</b></td></tr>
<tr><td><a href="http://herculist.com/members/index.cgi?<?=$herculink?>">Click here to join</a></td></tr>
<tr><td>Enter your HercuList username below<br>
<? if ($hercuupdated == $itisnot) { ?>
http://www.herculist.com/members/index.cgi?<input name="hercunewlink" type="text"></td></tr>
<? } elseif ($hercuupdated == $itis) { ?>
http://www.herculist.com/members/index.cgi?<input name="hercunewlink" type="text" value="<?=$hercunow?>"></td></tr>
<? } ?>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr><td><b>ProMoneyMail</b></td></tr>
<tr><td><a href="http://www.promoneymail.com/member<?=$promoneylink?>">Click here to join</a></td></tr>
<tr><td>Enter your ProMoneyMail ID NUMBER below<br>
<? if ($promoneyupdated == $itisnot) { ?>
http://www.promoneymail.com/member<input name="promoneynewlink" type="text"></td></tr>
<? } elseif ($promoneyupdated == $itis) { ?>
http://www.promoneymail.com/member<input name="promoneynewlink" type="text" value="<?=$promoneynow?>"></td></tr>
<? } ?>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr><td><b>Safe Lister</b></td></tr>
<tr><td><a href="http://www.safelister.com/index.cgi?id=<?=$safelisterlink?>">Click here to join</a></td></tr>
<tr><td>Enter your Safe Lister username below<br>
<? if ($safelisterupdated == $itisnot) { ?>
http://www.safelister.com/index.cgi?id=<input name="safelisternewlink" type="text"></td></tr>
<? } elseif ($safelisterupdated == $itis) { ?>
http://www.safelister.com/index.cgi?id=<input name="safelisternewlink" type="text" value="<?=$safelisternow?>"></td></tr>
<? } ?>
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr><td align="center"><input type="submit" name="Submit" value="Save"></td></tr>
</table>
</form>
After I submit the form, I receive "Your info were NOT updated". Meaning, that the error is in that $query line where I post to the database.PHP Code:<?
session_start();
if (!isset($_SESSION['username'])) {
die('An error has ocurred. You have not logged in, or your session has expired.');
exit();
}
// Connect to the database server
$dbcnx = @mysql_connect("localhost", "user", "pass");
if (!$dbcnx) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
// Select the database
if (! @mysql_select_db("needforcash_com") ) {
echo( "<p>Unable to locate the MarketingH2O " .
"database at this time.</p >" );
exit();
}
$sql = mysql_query("SELECT * FROM users WHERE username='$username'");
$lookup = mysql_fetch_assoc($sql);
$tacticsoldlink = $lookup['tacticsusername'];
$allmylistoldlink = $lookup['allmylistusername'];
$bwloldlink = $lookup['bwlusername'];
$hercuoldlink = $lookup['hercuusername'];
$promoneyoldlink = $lookup['promoneyusername'];
$safelisteroldlink = $lookup['safelisterusername'];
// Define post fields into simple variables
if(empty($_POST['tacticsnewlink'])) {
$tacticsnewlink = $tacticsoldlink;
$tacticsupdated = "no";
} else {
$tacticsnewlink = $_POST['tacticsnewlink'];
$tacticsupdated = "yes";
}
if(empty($_POST['allmylistnewlink'])) {
$allmylistnewlink = $allmylistoldlink;
$allmylistupdated = "no";
} else {
$allmylistnewlink = $_POST['allmylistnewlink'];
$allmylistupdated = "yes";
}
if(empty($_POST['bwlnewlink'])) {
$bwlnewlink = $bwloldlink;
$bwlupdated = "no";
} else {
$bwlnewlink = $_POST['bwlnewlink'];
$bwlupdated = "yes";
}
if(empty($_POST['hercunewlink'])) {
$hercunewlink = $hercuoldlink;
$hercuupdated = "no";
} else {
$hercunewlink = $_POST['hercunewlink'];
$hercuupdated = "yes";
}
if(empty($_POST['promoneynewlink'])) {
$promoneynewlink = $promoneyoldlink;
$promoneyupdated = "no";
} else {
$promoneynewlink = $_POST['promoneynewlink'];
$promoneyupdated = "yes";
}
if(empty($_POST['safelisternewlink'])) {
$safelisternewlink = $safelisteroldlink;
$safelisterupdated = "no";
} else {
$safelisternewlink = $_POST['safelisternewlink'];
$safelisterupdated = "yes";
}
$query = mysql_query("UPDATE users SET tacticsusername='$tacticsnewlink', tacticsupdated='$tacticsupdated', allmylistusername='$allmylistnewlink', allmylistupdated='$allmylistupdated', bwlusername='$bwlnewlink', bwlupdated='$bwlupdated', hercuusername='$hercunewlink', hercuupdated='$hercuupdated', promoneyusername='$promoneynewlink', promoneyupdated='$promoneyupdated', safelisterusername='$safelisternewlink', $safelisterupdated='$safelisterupdated' WHERE username='$username'");
if (!$query) {
echo 'Your info were NOT updated.';
} else {
echo 'your info were updated successfully.';
}
?>
I've gone over the two scripts all day. I can't see why it's not updating the info in the database!
Strangely, the above all worked before I added the:
variables!!PHP Code:$tacticsupdated, $allmylistupdated, $bwlupdated, $hercuupdated, $promoneyupdated, $safelisterupdated
Can someone spot the problem?
Thanks. I appriciate any help.





For the future, it's easier to spot errors when formatting queries like that.

Bookmarks