Jump to content

updating database


franknu

Recommended Posts

i need to know why this database is not updating, i am getting the text from the database but it is not updating

 

 

here is my code

 

<?php

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


$Picture2 =  (isset($_POST['Picture2']) ? $_POST['Picture2']:'');
$Picture3 = (isset($_POST['Picture3']) ? $_POST['Picture3']:'');
$Picture4 =  (isset($_POST['Picture4']) ? $_POST['Picture4']:'');
$User_Name = (isset($_POST['User_Name']) ? $_POST['User_Name']:'');
$Password = (isset($_POST['Password']) ? $_POST['Password']: '');

$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)) {


$BusinessName= $row['BusinessName'];
$Keyword = $row['Keyword'];
$Picture1 =  $row['Picture1'];
$Headline = $row['Headline'];
$Slogan =$row['Slogan'];
$Slogan2 = $row['Slogan2'];
$Description1 =$row['Description1'];
$Description2 = $row['Description2'];
$Description3= $row['Description3'];
$Contact2 =  $row['Contact2'];
$Picture2 = $row['Picture2'];
$Picture3 = $row['Picture3'];
$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}', `Keyword`='{$Keyword}', `Picture1`='{$Picture1}',
               `Headline`='{$Headline}', `Slogan2`='{$Slogan2}', `Description1`='{$Description1}',
               `Description2`='{$Description2}', `Description3`= '{$Description3}',
               `Picture2`='{$Picture2}', `Picture3`='{$Picture3}',
               `Password`='{$Password}' WHERE `User_Name`='{$User_Name}'";


$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"<td>";

          echo"Address"
          ;
          echo"</td>";
          echo"<td> <input type='text' name='Business_Address' value='$Business_Address'>";
          echo" </td>";

       echo" </tr>";

			  echo"</td>";
          echo"<td>";
          echo"Category";
          echo"</td>";

          echo"<td>";

echo" <TEXTAREA ROWS=5 COLS=65  NAME='Categories' value='$Categories'> $Categories </TEXTAREA>";
          echo"</td>";

        echo"</tr>";
      echo"</table>";
  echo"<table>";
        echo"<tr>";
          echo"<td>";
          echo"Business  Webpage";
          echo"</td>";
        echo"</tr>";
        echo"<tr>";
          echo"<td>";
          echo"Headline";
          echo"</td>";
        echo"</tr>";
        echo"<tr>";
         echo" <td> <input type='text' name='Headline' value='$Headline'>";
         echo" </td>";

        echo"</tr>";
        echo"<tr>";
          echo"<td>";
          echo"Slogan";

           echo"</td>";
        echo"</tr>";
        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"</tr>";
        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"</tr>";
echo"</table>";

}

?>

 

thank u

Link to comment
Share on other sites

i echo every line because i was getting a parser error with out it so i decided to keep i tlike that

 

i think that problem is here

 



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}', `Keyword`='{$Keyword}', `Picture1`='{$Picture1}',
               `Headline`='{$Headline}', `Slogan2`='{$Slogan2}', `Description1`='{$Description1}',
               `Description2`='{$Description2}', `Description3`= '{$Description3}',
               `Picture2`='{$Picture2}', `Picture3`='{$Picture3}',
               `Password`='{$Password}' WHERE `User_Name`='{$User_Name}'";


$result = mysql_query($query) or die (mysql_error());
}

 

maybe i should change to submit any idea

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.