/    Sign up×
Community /Pin to ProfileBookmark

updating database

hi i need a help updating database

here is my code

[code=php]

$db = mysql_connect($host, $username, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());

$User_Name=strtolower($_POST[‘User_Name’]);
$Password=strtolower($_POST[‘Password’]);

$usercheck = mysql_query(“SELECT * FROM business_info where
User_Name=’$User_Name’ AND Password=’$Password'”,$db);
$userrow = mysql_fetch_array($usercheck);
$num_rows = mysql_num_rows($usercheck);

$query = “SELECT * FROM business_info where User_Name=’$User_Name’ AND Password=’$Password'”;
$result = mysql_query($query);

while ($row = mysql_fetch_assoc($result)) {

$Categories=$row[‘Categories’];
$Business_Address= $row[‘Business_Address’];
$make=$row[‘make’];
$type=$row[‘type’];
$Tel= $row[‘Tel’];
$Website=$row[‘Website’];
}

if ($num_rows!=1)
{
print “<p><b>username and/or password not found. Try
again?</b></p>”;
}
else

{

echo”<table border=’0′>”;
echo” <tr>”;

echo “Welcome to the The member session<br>
here you can update your webpage<br>”;

//start here

$query = “SELECT * FROM business_info WHERE `BusinessName`= ‘$BusinessName’
AND `User_Name`=’$User_Name'”;

$result = mysql_query($query) or die (mysql_error());
$res2 = mysql_fetch_assoc($result);

echo “$BusinessName”;

if(isset($_GET[‘update’]))
{

$query=”UPDATE business_info SET `BusinessName`= ‘$BusinessName’, `Slogan`='{$Slogan}’,
`Business_Address`='{$Business_Address}’, `Tel`='{$Tel}’, `Website`=’$Website’,
`Email`='{$Email}’, `Fax`='{$Fax}’, `type`='{$type}’,
`make`='{$make}’, `Categories`='{$Categories}’,
$result = mysql_query($query) or die (mysql_error());
}

echo”<table bgcolor=’ffffff’>”;
echo”<tr>”;
echo”<td>”;
echo”<table>”;
echo”<tr>”;

echo”</tr>”;
echo”</table>”;
echo”</td>”;
echo”</tr>”;
echo”<tr>”;
echo”<td></td>”;
echo”</tr>”;
echo”<tr>”;
echo”<td>”;
echo”<table> “;
echo” <tr>”;

echo”<td>”;

echo”<table bgcolor=’ffffff ‘>”;
echo” <tr>”;
echo”<td>”;
echo”<table>”;
echo”<form action=”{$_SERVER[‘PHP_SELF’]}” method=’Post’>”;

echo”<tr>”;
echo”<tr>”;
echo” <td> <input type=’text’ name=’Headline’ value=’$Headline’>”;
echo” </td>”;

echo”<tr>”;
echo”<td> <input type=’text’ name=’Slogan2′ value=’$Slogan2′>”;
echo”</td>”;
echo” </tr>”;
echo”<tr>”;
echo” <td>”;
echo”Description1″;
echo” </td>”;
echo”</tr>”;
echo”<tr>”;
echo”<td>”;
echo”<TEXTAREA ROWS=5 COLS=65 NAME=’Description1′ value=’$Description1′>$Description1 </TEXTAREA> “;

echo”<td>”;
echo”Description3″;
echo”</td>”;
echo”</tr>”;
echo”<tr>”;
echo”<td><TEXTAREA ROWS=5 COLS=65 NAME=’Description3′ value=’$Description3′>$Description3</TEXTAREA>”;
echo”</td>”;
echo”</tr>”;

echo” <tr>”;
echo” <td>”;

echo”<table>”;
echo”<tr>”;
echo”<td>”;
echo”User Name”;
echo”</td>”;
echo”<td> <input type=’text’ name=’User_Name’ value=’$User_Name’>”;
echo”</td>”;
echo”<td>”;
echo”Password”;
echo”</td>”;
echo”<td> <input type=’text’ name=’Password’ value=’$Password’>”;
echo”</td>”;
echo”</tr>”;
echo”</table>”;
echo”</td>”;
echo”</tr>”;
echo”</table>”;
echo” </td>”;
echo”</tr>”;
echo”<tr>”;
echo”<td>
<input type=’submit’ value=’Update my database’ name=’update’ />
<input type=’reset’ value=’Reset fields’ />”;
echo”<td> “;
echo”</form>”;

echo”</table>”;

echo”</td>”;
echo”<td>”;
echo”</td>”;
echo” </tr>”;
echo”</table>”;
echo”</td>”;
echo”</table> ” ;
echo” </tr>”;

//finish here
echo “<td> </td>”;
echo”</td>”;
echo”<td valign=’top’>”;

echo”</td>”;
echo”</tr>”;
echo”</table>”;

echo”</td>”;
echo”</tr>”;
echo”</table>”;

}

?>

</body>
</html>

[/code]

i dont know why i cant update it, when i hit the update botom just take me back to what was there already

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@tcaMar 24.2007 — First, your form method is "post". You are using a $_GET. Change to if(isset($_POST['update']))

Second, loose the and the { } in your query.

Third, add a in echo"<form action="{$_SERVER['PHP_SELF']}" method='Post'>"; >>> echo"<form action="{$_SERVER['PHP_SELF']}" method='Post'>";
Copy linkTweet thisAlerts:
@NightShift58Mar 24.2007 — First, your form method is "post". You are using a $_GET. Change to if(isset($_POST['update'])) [/quote]Correct.

Second, loose the and the { } in your query.[/quote]Lose the {} but definitely keep the `` - it's a good habit to have and keep.

Third, add a in echo"<form action="{$_SERVER['PHP_SELF']}" method='Post'>"; >>> echo"<form action="{$_SERVER['PHP_SELF']}" method='Post'>";[/QUOTE]Be consistent and use:[code=php]echo"<form action='{$_SERVER['PHP_SELF']}' method='Post'>";[/code]since you're using single quotes for method. Better, however, would be:[code=php]echo"<form action='' method='post'>";[/code]
Copy linkTweet thisAlerts:
@tcaMar 24.2007 — 
but definitely keep the ` - it's a good habit to have and keep.
[/quote]</QUOTE>

Interesting... I used to do that, but about three severs ago (don't remember the exact version of PHP, but it was 4 something) all my queries quit working until I removed the <C>
</C>. I just changed one query using my current server (PHP/4.3.10) and, of course, it works fine. Making a note to add <C> ` in all future queries.

TC
Copy linkTweet thisAlerts:
@NightShift58Mar 25.2007 — The backticks are not a PHP issue but more so MySQL.

It never hurts to have, especially when "funny" field and table names slip into the system.
×

Success!

Help @franknu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...