Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 12th, 2006, 01:06 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default query for identical field and echo...

Hello all,

I have a questionaire that consists of four pages. Hidden fields are used to carry the information from page to page. The code below is from the first page. I am trying to query the database to see if the propertyname already exists; if it does, to echo an error while keeping the other user-entered information intact. Here's what I've come up with so far, but in preview nothing happens when I enter an already used propertyname. Any help would be most appreciated!


<?php require_once('Connections/connectdb.php'); ?>
<?php
$connectdb;
@mysql_select_db(rentlogin) or die( "Unable to select database");
$Propertyname = $_POST['Propertyname'];
$check = mysql_query("select Propertyname from owner_prop where Propertyname=\"$Propertyname\"");
$returned = mysql_fetch_array($check);
if (isset($_POST['Propertyname']))
    if(!empty($returned))
{ echo 'Propertyname already exists, please choose another name.';
        mysql_close($connectdb);
                Die();
}

?>
Reply With Quote
  #2 (permalink)  
Old January 15th, 2006, 12:59 PM
Friend of Wrox
 
Join Date: Dec 2004
Location: London, London, United Kingdom.
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I understand what you are trying to do but it seams just too complicated for me :S and since no one replied:
<?php
$Propertyname1 = $_POST['Propertyname'];
@$dbh=mysql_connect ("localhost", "database username here" , "database password here") or die ('There was a problem connecting to the database - please press refresh');

@mysql_select_db ("rentlogin");
$query = "SELECT * FROM owner_prop WHERE Propertyname LIKE '$Propertyname1'";
$result = mysql_query($query) or die ("There was a problem connecting to the database - please press refresh");
$Propertynameexist="";
while ($row = mysql_fetch_array($result))
  {
     extract($row);
     $Propertynameexist = $Propertyname; }

if ( $Propertynameexist != "" ) { die ("Property name already exist"); }
if ( $Propertynameexist == "" )
{
.
.
.
}
?>
Reply With Quote
  #3 (permalink)  
Old January 15th, 2006, 05:48 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Mantis. I appreciate your input. I'll take what you have and try to rework the code!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ex10_01 Identical code, different output tonyjeffs BOOK: Ivor Horton's Beginning Visual C++ 2005 4 December 7th, 2007 05:50 AM
Finding identical values voskoue Access VBA 7 January 30th, 2007 08:43 AM
Identical results in Drop Down List 5ilverado ASP.NET 1.0 and 1.1 Professional 0 July 3rd, 2006 12:26 AM
Problem with echo from query result Steve Newbie MySQL 2 August 16th, 2004 11:48 AM
multiple definitions with identical signatures Galina Crystal Reports 0 February 14th, 2004 05:39 PM



All times are GMT -4. The time now is 09:56 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.