no selecting data

This is a discussion on "no selecting data" within the PHP Forum section. This forum, and the thread "no selecting data are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 25th, 2007, 20:30
Junior Member
Join Date: Jun 2006
Location: usa
Age: 29
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation no selecting data

Ok, I am having Some issues now, My main problem now is that it is not selecting from database. Meaning

it is not display the value from the database when i ask it to do so.


here is partial part of the code

PHP: Select all

 
$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']: '');
$User_Name=strtolower($_POST['User_Name']);
$Password=strtolower($_POST['Password']);
 
if ( isset($_POST['User_Name']) && isset($_POST['Password']) ) {
 
 
$query = "SELECT * FROM business_info where User_Name='".$_POST['User_Name']."' AND `Password`='".$_POST['Password']."'";
 
 
}
 
  if ($result = mysql_query($query)) 
{
    if (mysql_num_rows($result))
 {
      $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'];
    } 
else 
{
      echo "<p><b>username and/or password not found. Try
again?
 
</b></p>";
exit;
    }
  } 
else 
{
    echo "Query failed<br />$query<br />". mysql_error();
exit;
  }
 
?>
 
 
 
 
 
 
<?
echo
<
table width="504" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
<
tr>
<
td width="494"><table width="497" border="0">
<
tr>
<
td width="487">Banner</td>
</
tr>
<
tr>
 
 
 
 
// like this line down here should display name from database INSTEAD Is
displayin (Welcome $BusinessName )
 
<
td background="fondo2.jpg">Welcome $BusinessName </td>
 
</
tr>
<
tr>
<
td><table width="480" border="0">
<
tr>
Reply With Quote

  #2 (permalink)  
Old May 26th, 2007, 02:40
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: no selecting data

Try printing out $query and seeing the SQL you're actually running. That should give you a clue as to what is wrong. I suspect the backtics around Password ...
Reply With Quote
  #3 (permalink)  
Old May 26th, 2007, 15:58
Junior Member
Join Date: Jun 2006
Location: usa
Age: 29
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Re: no selecting data

ok print our $query and this is what is shows;

SELECT * FROM business_info WHERE User_Name='franklin' AND `Password`='franklin01'

i think that maybe the problem is in the way i am echoing the the data

like i am echoing the whole html codes in only one

example

<?
echo'

html codes';

?>

could that be the problem
Reply With Quote
  #4 (permalink)  
Old May 26th, 2007, 17:43
Reputable Member
Join Date: Jul 2005
Location: Melksham, Wilts, UK
Posts: 293
Thanks: 0
Thanked 0 Times in 0 Posts
Re: no selecting data

You do NOT want the quote around the word password in the query, as I suspected in my previous answer. Take them out. As the code is written, you are testing if the literal string "password" is the same as the literal string "franklin01" which it never is. You probably want to test if the string in the column called password is equal t the string "franklin01" instead.
Reply With Quote
  #5 (permalink)  
Old May 26th, 2007, 18:08
Junior Member
Join Date: Jun 2006
Location: usa
Age: 29
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Re: no selecting data

Well, i guess i was right it, is the was echo was set up for whatever reason it did not like it

thank u
Reply With Quote
Reply

Tags
selecting from database

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
selecting a TextInput from within a symbol cosmicbdog Flash & Multimedia Forum 5 May 23rd, 2007 15:10
Problem selecting elements Echilon Web Page Design 2 Jan 3rd, 2007 11:43
Selecting certain XML elements fogofogo Other Programming Languages 3 Dec 5th, 2005 12:49
Selecting Numbers WillisTi Flash & Multimedia Forum 1 Nov 16th, 2005 16:56
selecting a value from array Ozeona Flash & Multimedia Forum 2 Jul 27th, 2005 10:14


All times are GMT. The time now is 07:26.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43