Reply
Please Help With PHP Database..
Old 08-02-2004, 12:23 AM Please Help With PHP Database..
keira's Avatar
Novice Talker

Posts: 7
Hiya

I am currently trying to learn how to make a database using mysql and php, & have come to a problem with my php program

the programs aim is to add a new property to a property listing in a real estate web site, but i cannot get my program to submit all the information that is entered via forms

if you check out http://www.judithgriggrealestate.com/choosePropType.php
and add a property for yourself to see, (dont worry i will be deleting these entries when i have completed writing the program) you will notice on the last page - the 'feedback' page, all the information does not show

if anybody is willing to help me, i can post more information or more coding so this makes more sense..

please please, it would be sooo much appreciated!!!
keira is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 08-03-2004, 11:58 PM
keira's Avatar
Novice Talker

Posts: 7
BUMP!!!

Please help me guys.. ..

ive worked some of this out, had to do with forwarding the variables on to the next part of the program with a form . ..

but i still can't get some of the information to get entered into the database, i can't see what im doing wrong..


this is the code for the prog that allows the user to enter information to submit to the database..
PHP Code:
<?php
/* Program: chooseSuburb.php
 * Desc:       Allows the user to enter the information for the property. First, the program checks
 *                for a new category and enters it into the propertyType table if it is new.  Then, all 
 *                properties in the selected category are displayed with radio buttons. The user can 
 *                enter a new name. Fields are provided to enter the description, price, and picture 
 *                file name
 */
?>
<?php
if (@$newbutton == "Return to property type page" or
    @
$newbutton == "Cancel")
     {
header("Location: choosePropType.php");
      }
?>
<html>
<head><title>Add Property</title></head>
<body>
<?php
     
include("***.inc");
     include(
"functions.inc");
     
     
$connection mysql_connect($host$user$password)
            or die (
"couldn't connect to server");
     
$db mysql_select_db($database,$connection)
           or die (
"couldn't select database"); 

/* if new was selected for property type, check if text fields were filled in. if they were not filled in,
 display them again for the user to enter the type and type description. when the 
 fields are filled in, store the new type in the propertyType table.*/
    
if($propType == "new")
{
    if (
$newType == " " or $newDesc == " ")
       {
       include(
"newType_form.inc");
       exit();
        }
       
/* add new suburb to property table */
      
else
           {
           
addNewType($newType$newDesc);
           
$propType $newType;
            }
}

 
/* Select suburb names from table with giventype. if user entered a new type, it is     
 searched for. */
$query "Select distinct propSuburb from property
                where propType='$propType' ORDER BY propSuburb"
;
$result mysql_query($query)
                or die (
"Couldn't execute query 3.");
$nrow mysql_num_rows($result);

/* create form */
echo "<div style='margin-left: .1in'>";
echo 
"<form action='addProperty.php' method='post'>\n";
echo 
"<p><b>Suburb</b></p>\n";
if (
$nrow 1)
{
      echo 
"<hr><b>No suburb names are currently in the database for the type          
                           $propType</b><hr>\n"
;
}
else
{
     echo 
"<table cellpadding='5' border='0'>";
     echo 
"<tr>";
     while (
$row mysql_fetch_array($result) )
     {
              
extract($row);
              echo 
"<td>";
              echo 
" <input type='radio' name='newSuburb' value='$propSuburb' ";
              echo 
" >$propSuburb</td>\n";
     }
     echo 
"</tr></table>";
}
include(
"newSuburb_table.inc");

$propDetails=" "$propPrice =" "$propImage =" "
include(
"propInfo_table.inc");

echo 
"<input type='hidden' name='propType'
                value='$propType'>\n"
;

 echo 
"<input type='hidden' name='propPrice'
                value='$propPrice'>\n"
;

 echo 
"<input type='hidden' name='propImage'
                value='$propImage'>\n"
;


echo 
"<p><input type='submit' value='Submit Suburb Name'>
              <input type='submit' name='newbutton' value='Cancel'>
              </form>\n"
;
?>
</div>
</body>
</html>

and this is the code for the programs that ads it and shows the feedback page..

PHP Code:
<?php
/* program: addProperty.php
    Desc:  add new property to the database. a confirmation screen is sent to the user
*/

if (@$newbutton == "Cancel")
{
       
header("Location: choosePropType.php");
}
if (
$propSuburb == "new")
  {
    if (
$newSuburb == "")
    {
        include(
"newSuburb_form.inc");
         exit();
}
else
{
$propSuburb ucfirst(strtolower(strip_tags(trim($newSuburb))));
}
}
if (
$propImage == "")
$propImage ="na.gif";
?>
<html>
<head><title>Add Property</title>
</head>
<body>
<?php
include("***.inc");
$connection mysql_connect($host,$user,$password)
   or die (
"Couldn't connect to server");
$db mysql_select_db($database,$connection)
  or die (
"Couldn't select database");


$query "INSERT INTO property (propType, propName, propDetails, propPrice, propImage, address, propSuburb,  propFeatures)
VALUES
('$propType', '$propName', '$propDetails', '$propPrice', '$propImage', '$address', '$propSuburb',  '$propFeatures' )"
;
$result mysql_query($query)
  or die (
"Couldn't execute query");
$propId mysql_insert_id();

echo 
"The following property has been added to the Property Listing:<br>
<ul>
<li>Property Type: $propType
<li>Property Name: $propName
<li>Property Details: $propDetails
<li>Price: $propPrice
<li>Picture File: $propImage
<li>Address: $address
<li>Suburb: $propSuburb
<li>Features: $propFeatures
 \n"
;
echo 
"</ul>";
echo 
"<a href='choosePropType.php'>Add another property</a>\n";
?>
</body?
</html>
is this enough info??

Last edited by Kyrnt : 08-04-2004 at 06:59 AM. Reason: Put PHP code in code block
keira is offline
Reply With Quote
View Public Profile
 
Old 08-04-2004, 06:10 AM
Experienced Talker

Posts: 31
Which fields can you not enter?
urbanite is offline
Reply With Quote
View Public Profile
 
Old 08-04-2004, 07:00 AM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Keira,

Could you give us more information on exactly what information isn't making it into the database? Is it always the same fields? Is the behavior constant or intermittent?
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 08-04-2004, 09:26 PM
keira's Avatar
Novice Talker

Posts: 7
sorry!

the fields that never make it in are:

- Picture file, ($propImage)
- price ($propPrice) &
- suburb ($propSuburb) - but suburb only doesnt work if it is a new suburb,
if you choose from an exisiting suburb, it works fine..

does this help??
keira is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Please Help With PHP 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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14169 seconds with 12 queries