Jump to content

how to do this query i am getting a parser error


franknu

Recommended Posts

<?
if ( isset($_SESSION['User_Name']) && isset ($_SESSION['Password']) ) 
{


$query = "SELECT * FROM business_info where $_SESSION['User_Name'] AND $_SESSION['Password']";
}

?>

my error

arse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/townsfin/public_html/authorization/text_update.php on line 69

<?php
//database connection.

if ( isset($_SESSION['User_Name']) && isset ($_SESSION['Password']) ) 
{


$query = "SELECT * FROM business_info where ".$_SESSION['User_Name']." AND ".$_SESSION['Password']."" ;
$result=mysql_query($query);
}

?>

Note thats assumes

$_SESSION['User_Name'] = something like

user = 'username'

 

etc

 

maybe

$query = "SELECT * FROM business_info where user='".$_SESSION['User_Name']."' AND pass='".$_SESSION['Password']."'" ;

 

OR (i find this easier to read)

 

$query = "SELECT * FROM business_info where user='{$_SESSION['User_Name']}' AND pass='{$_SESSION['Password']}'" ;

 

 

of course change user & pass to the correct field names

 

 

well, i tried diffrent things and nothing is selecting from the database so i will  add more codes to give u guys  a better  idea here it is

 

<?php 
session_start(); 
$_SESSION['User_Name'];
$_SESSION['Password']; 

?>


<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
</head>

<body>
<?php
// i just removed data info
$host     = "";
$username = "ocalho";
$password = "abc123";
$database = "";

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



$BusinessName = (isset($_POST['BusinessName']) ? $_POST['BusinessName'] : '');
$Slogan = (isset($_POST['Slogan']) ? $_POST['Slogan']:'');
$Business_Address = (isset($_POST['Business_Address']) ? $_POST['Business_Address']:'');
$Tel = (isset($_POST['Tel']) ? $_POST['Tel']:'');
$Website = (isset($_POST['Website']) ? $_POST['Website']:'');
$Email = (isset($_POST['Email']) ? $_POST['Email']:'');
$Member_Status = (isset($_POST['Member_Status']) ? $_POST['Member_Status']:'');
$Fax =(isset($_POST['Fax']) ? $_POST['Fax']:'');
$type = (isset($_POST['type']) ? $_POST['type']:'');
$make = (isset($_POST['make']) ? $_POST['make']:'');
$Categories = (isset($_POST['Categories']) ? $_POST['Categories']:'');
$Keyword = (isset($_POST['Keyword']) ? $_POST['Keyword']:'');
$Picture1 =  (isset($_POST['Picture1']) ? $_POST['Picture1']:'');
$Headline =  (isset($_POST['Headline']) ? $_POST['Headline']:'');
$Slogan2 = (isset($_POST['Slogan2']) ? $_POST['Slogan2']:'');
$Description1 = (isset($_POST['Description1']) ? $_POST['Description1']:'');
$Description2 = (isset($_POST['Description2']) ? $_POST['Description2']:'');
$Description3= (isset($_POST['Description3']) ? $_POST['Description3']:'');
$Contact2 = (isset($_POST['Contact2']) ? $_POST['Contact2']:'');
$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']: '');


if ( isset($_SESSION['User_Name']) && isset ($_SESSION['Password']) ) 
{





$query = "SELECT * FROM business_info where User_Name='".$_SESSION['User_Name']."' AND Password='".$_SESSION['Password']."'" ;

$result=mysql_query($query);

}

?>



<table width="356" border="0">
  <tr>
    <td width="346"><table width="514" border="1">
<?
echo"$BusinessName";
$_SESSION['User_Name'];
$_SESSION['Password']; 
?>
<pre>_SESSION:<?php print_r($_SESSION); ?></pre> 



     <tr>
        <td width="504" background="fondo2.jpg"> </td>
      </tr>
      <tr>
        <td><table width="537" border="1" bordercolor="#E0DFE3" bgcolor="#CCCCCC">
          <tr> <?
	  echo'<form action="'. $_SERVER['PHP_SELF'].'" method="post" enctype="multipart/form-data">';
	  ?>
            <td width="67">Business Name </td>
            <td width="148">
		<?
		echo" 

		<input type=\"text\" name=\"BusinessName\" value=\"{$row['BusinessName']}\">  "; 
		?>

 

thank u

i fixed the parser and this should display the results if it is selecting from database

 

 

$result=mysql_query($query);

<?

 

echo"BusinesName";

?>

 

this is my Display when  i echo the query

 

SELECT * FROM business_info where User_Name='franklin' AND Password='franklin01'

and this should display the results if it is selecting from database

 

<?

 

echo"BusinesName";

?>

 

How? All that will echo is the words BusinesName.

 

An example..

 

<?php

  // connect

  if ($result = mysql_query("SELECT foo FROM tbl")) {
    if (mysql_num_rows($result)) {
      while($row = mysql_fetch_assoc($result)) {
        echo $row['foo'].'<br />';
      }
    }
  }

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.