my sql is not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

my sql is not working

Post by franknu »

ok i have this code to update the database the problem is that my sql is not working for some odd reason maybe because it is inside an php script

here is my code

Code: Select all

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

{
echo " Welcome";
echo'


<table border="0">
 <tr>

   <td valign="top">
   <table border="0">
        <tr>

        <td bgcolor="cococo">
<a href="index.php">

Home

<font color="cococo">ddddddddddddddddddddd</font>

</a>
		</td>

        </tr>
        <tr>
          <td>


		welcome $BusinessName,  
<font color="ffffff">dddddddddddddddddddfffffffffffffffffffdd</font> 
		  </td>
           </tr>
          </table>
        <table background="../images/fondo2.jpg"  border="1" valign="top">
          <tr> 
          <td valign="top">
		  <table border="1" background="../images/fondo2.jpg" valign="top">

<tr> 
            <td>
		  <a href= "http://entrepreneur.com">Pictures Uploads/change</a>
		  </td>
          </tr>

          <tr>
            <td>
		  <a href= "http://entrepreneur.com">Advertise your website</a>
		  </td>
          </tr>
          <tr> 
           <td>
		  </td>
          </tr>
          <tr> 
           <td>
<a href="http://69.89.27.201:2082/horde/index.php/">Email</a>
		 </td>
           </tr>
              <tr> 
                <td>
								</td>
              </tr>
              <tr>
                <td>
		<a href="http://www.nasdaq.com">Stock Market</a>
				</td>

              </tr>
            </table>
			</td>
          <td  valign="top"> 

            <center><table border="1">
			  <tr>
               <td>




<a href=\"update.php?update=true\">update</a>







			</td>
                <td>
	<a href=\"keyword.php?keyword=true\">Add Key words</a>
				</td>
                <td>
				<a href="http://www.ccbill.com">CCBILL</a>
				</td>
              </tr>

            </table>

</center>

// display codes
			 
$sql = "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); 



$BusinessName

 if(isset($_POST["submit"]))
 
{
$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());


}




<table bgcolor="ffffff">
  <tr>
    <td>
        <table>
          <tr>

                     </tr>
        </table>
      </td>
  </tr>
  <tr>
    <td></td>
  </tr>
  <tr>
    <td>
    <table> 
        <tr>

		  <td>

		<table bgcolor="ffffff ">
 <tr>
  <td>
<table>
<form action="<?php echo $_SERVER["PHP_SELF"] method="Post" ?>";> 






<tr>
    <td>
    Busiess Info
   </td>
  </tr>
  <tr>
    <td>
    <table>
        <tr>
          <td>
          Business Name
          </td>
          <td>






<input type="text" name="BusinessName"  Value="$BusinessName">

          </td>

        </tr>
        <tr>
          <td>
          Slogan
          </td>

          <td>

          <input type="text" NAME="Slogan" value="$Slogan">

          </td>
          <td>
          Website
          </td>

          <td> <input type="text" name="Website" value="$Website">
          </td>
       </tr>

        <tr>';

here is my display

Code: Select all

$sql = "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); $BusinessName if(isset($_POST["submit"])) { $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()); } 
 
 
";>

also on the values for the form all i get is $VARIABLES

please help
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

There's a massive string in the first snippet that doesn't end until the end of the snippet. PHP code appears to be inside that string, but it won't be executed while inside it.
Begby
Forum Regular
Posts: 575
Joined: Wed Dec 13, 2006 10:28 am

Post by Begby »

This is because you are echoing all that stuff in single quotes and also don't have any PHP tags surrounding your other code within that echo (where the query is)
franknu
Forum Contributor
Posts: 146
Joined: Sun May 28, 2006 9:29 am

Post by franknu »

well, i echo the database and it gives me an error

i mean i can echo every single line of codes and can work i just thought i was a big mess

it is that the only way this can work
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

what they are telling you is

Near the top you have an echo '

then your ending single quote ' is at the very end of the snippet.

None of the php variables etc in between these single quotes will be evaluated.

So the entire thing just prints out literally everything in between the single quotes.

If your code snippet is wrong then I suggest you post the correct snippet. If this doesn't make sense then we probably cant help you.

Variables only evaluate when they are placed between " double quotes, not ' single quotes. If you enclose in 2 double quotes any double quotes within the string need to be escaped \"

Can I suggest you start with some basic PHP tutorials and learn to walk before you run
Post Reply