Lassie
-
Posts
390 -
Joined
-
Last visited
Posts posted by Lassie
-
-
Thanks for your reply.
I inserted your code line and ran it but I get no errors and no db update.
As I said this is part of the whole form and I have condensed it to try and get he insert to work.
There are other columns in the table and I have had the error 'Column count doenst match value count at row 1' in the main program. I thought maybe the date was the problem. The column count and value count are equal so I am a little lost.
Any thoughts?
-
I have form which allows a user to select a date as part of the form.
On submitting i am getting no update to the database and no error message.
To try and test it i created a shorter version which sets up the variables except the date.This gives the same result.ie no update.
The date prints out correctly as a variable.
What else can i do to find the error?
<?php #register property // Include the configuration file for error management and such. require_once ('./includes/config.inc.php'); // Set the page title and include the HTML header. $page_title = 'Register a Property'; session_start(); include ('./includes/header.html'); require_once ('./mysql_connect2.php'); // Connect to the database. // Handle the form. if (isset($_POST['submitted'])) { //Check availability for sale. if($_POST['month']) { $m= escape_data($_POST['month']); } else{ $m = FALSE; echo '<p><font color="red" size="+1">Please enter month!</font></p>'; } //Check availability for sale. if($_POST['day']) { $dy= escape_data($_POST['day']); } else{ $dy = FALSE; echo '<p><font color="red" size="+1">Please enter day of month!</font></p>'; } //Check availability for sale. if($_POST['year']) { $y= escape_data($_POST['year']); } else{ $y = FALSE; echo '<p><font color="red" size="+1">Please enter year!</font></p>'; } if (!checkdate($m,$dy,$y)) { $error = 'You have used an invalid date'; } else { $dy = $dy < 10 ? '0'.$dy : $dy; $mysqlFormat = "$y-$m-$dy"; $av=$mysqlFormat; } }else{ echo "Your Property could not be registered due to a system error.Please contact admin@homeownersdirect"; } //set the variables $v= 12; $rc=456; $rn="stockies resort"; $ct="Spain"; $rg="Almeria"; $tp="T1"; $un=23; $ft="ground"; $ow="floating"; $cl="red"; $oc=12; $bk="yes"; $p=3000; $o="yes"; $t="hutchinson"; $d="fhfgfhf"; echo "<br />"; echo "$v<br />"; echo "$rc<br />"; echo "$rn<br />"; echo "$ct<br />"; echo "$rg<br />"; echo "$tp<br />"; echo "$un<br />"; echo "$ft<br />"; echo "$ow<br />"; echo "$cl<br />"; echo "$oc<br />"; echo "$bk<br />"; echo "$av<br />"; echo "$p<br />"; echo "$o<br />"; echo "$t<br />"; echo "$d<br />"; //add the property $query = "INSERT INTO property (v_id,rci_ref,resort_name,country,region,unit_desc,unit_num,floor_type,ownership,floating, occ_wk ,booked,price,available,offers,trustees,description) VALUES ('$v','$rc','$rn','$ct','$rg','$tp','$un','$ft','$ow','$cl','$oc','$bk','$av','$p','$o','$t','$d')"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); //set date ?> <h1>Select Date available</h1> <form action="db_test" method="post"> <fieldset> <legend>Select Date</legend> <?php // This script makes three pull-down menus for an HTML form: months, days, years. // Make the months array. $month = array (1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); // Make the months pull-down menu. echo '<select name="month">'; foreach ($month as $key => $value) { echo "<option value=\"$key\">$value</option>\n"; } echo '</select>'; // Make the days pull-down menu. echo '<select name="day">'; for ($day = 1; $day <= 31; $day++) { echo "<option value=\"$day\">$day</option>\n"; } echo '</select>'; // Make the years pull-down menu. echo '<select name="year">'; $year = 2007; while ($year <= 2015) { echo "<option value=\"$year\">$year</option>\n"; $year++; } echo '</select>'; ?> </fieldset> <div align="center"><input type="submit" name="submit" value="submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> </form>
-
Hi , Sorry I dont have MSN.
The url is http://217.46.159.226/timeshare5/js2.php.
I had some errors the most significant seems to be this
'First argument to array_keys should be an array'
I put the body onload tag back in and the page now displays the drop down as intended.
Unfortunatley I am now getting an sql error when inserting a property registraion in the db.
So, in summary I think your code works well and I need to find my other errors.
Please take a look if you have time but I appreciate this has been long winded.
Thank you in any case for your help.
-
I have tried the test page.Is it intended to be stand alone as I dont get a populated drop down.
I notice that the body tag in the test page does not included the prevoius code:-
<body onload="setRegions();">#
Is this still required?
-
Thanks I'll give that ago and let u know.
-
Hi Mjadamato,
I checked the errors log and there is the following
line 18
First argument to array_keys() should be an array.
Could you just reiterate the order in which this code needs to fit together.
At present ihave the following
the js header with the php code to go through the region array etc
the php code at the top of the page to modify the region list
and the select code in the form.
Any help you can give is most appreciated.
-
Hi Mjdamato,
Sorry to be slow coming back - holiday commitments
You can find the page on this link
http://217.46.159.226/timeshare5/js2.php
The country drop down is not populating I forgot to mention.
Thanks for the validation suggestion. I will look at that.
-
Hi Mjadamato
Many thanks for you interest. I have tried the new version and get 2 script errors which i assume is js as follows
Line 17
Untermninated string constant
and
Line 57
Object expected.
I post both the page and the header with the js below.
Can you suggest how I fix this please.
php page
<?php #register property // Include the configuration file for error management and such. require_once ('./includes/config.inc.php'); // Set the page title and include the HTML header. $page_title = 'Register a Property'; session_start(); //********************************************************** //*** Modify regionlist to change the country/region options //********************************************************** $regionList['Spain'] = array('Almeria', 'Costa del Sol'); $regionList['France'] = array('Midi-Pyrenees', 'Languedoc-Roussillon','Aquitane'); $regionList['United States'] = array('Arizona','Florida'); //********************************************************** $countries = array_keys($regions); $countrySel = (isset($_POST['country']) && in_array($_POST['country'],$countries))?$_POST['country']:$countries[0]; $regions = $regionList[$countrySel]; $regionSel = (isset($_POST['region']) && in_array($_POST['region'],$regions))?$_POST['region']:$regions[0]; include ('./includes/header_js.htm'); $u= $_SESSION['user_id']; // Handle the form. if (isset($_POST['submitted'])) { require_once ('./mysql_connect2.php'); // Connect to the database. //check for rci reference if(isset($_POST['rci_ref']) && is_numeric($_POST['rci_ref'])) { $rc= escape_data($_POST['rci_ref']); } else{ $rc = FALSE; echo '<p><font color="red" size="+1">Please enter rci reference. Must be Numeric!</font></p>'; } //check for resort name if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['resort_name'])))) { $rn = escape_data($_POST['resort_name']); } else { $rn = FALSE; echo '<p><font color="red" size="+1">Please enter resort name!</font></p>'; } //check for Country if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['country'])))) { $ct = escape_data($_POST['country']); } else { $ct = FALSE; echo '<p><font color="red" size="+1">Please enter Country!</font></p>'; } //check for Region if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['region'])))) { $rg = escape_data($_POST['region']); } else { $rg = FALSE; echo '<p><font color="red" size="+1">Please enter region of the country!</font></p>'; } //Check type of accommodation. if($_POST['type']) { $tp= escape_data($_POST['type']); } else{ $tp = FALSE; echo '<p><font color="red" size="+1">Please select your unit type!</font></p>'; } //Check for unit number. if($_POST['unit_num']) { $un= escape_data($_POST['unit_num']); } else{ $un = FALSE; echo '<p><font color="red" size="+1">Please enter your unit number!</font></p>'; } //Check floor type. if($_POST['floor_type']) { $ft= escape_data($_POST['floor_type']); } else{ $ft= FALSE; echo '<p><font color="red" size="+1">Please select your floor type!</font></p>'; } //Check type of ownership. if($_POST['ownership']) { $ow= escape_data($_POST['ownership']); } else{ $ow = FALSE; echo '<p><font color="red" size="+1">Please select your ownership type!</font></p>'; } //Check type of period eg red, blue, etc. if($_POST['color']) { $cl= escape_data($_POST['color']); } else{ $cl = FALSE; echo '<p><font color="red" size="+1">Please indicate your period color!</font></p>'; } //Check for occupation week. if($_POST['occ_wk']) { $oc= escape_data($_POST['occ_wk']); } else{ $oc = FALSE; echo '<p><font color="red" size="+1">Please select your unit type!</font></p>'; } //Check type of booked weeks. if($_POST['booked']) { $bk= escape_data($_POST['booked']); } else{ $bk = FALSE; echo '<p><font color="red" size="+1">Please confirm if week booked or not!</font></p>'; } //Check availability for sale. if($_POST['month']) { $m= escape_data($_POST['month']); } else{ $m = FALSE; echo '<p><font color="red" size="+1">Please enter month!</font></p>'; } //Check availability for sale. if($_POST['day']) { $dy= escape_data($_POST['day']); } else{ $dy = FALSE; echo '<p><font color="red" size="+1">Please enter day of month!</font></p>'; } //Check availability for sale. if($_POST['year']) { $y= escape_data($_POST['year']); } else{ $y = FALSE; echo '<p><font color="red" size="+1">Please enter year!</font></p>'; } if (!checkdate($m,$dy,$y)) { $error = 'You have used an invalid date'; } else { $dy = $dy < 10 ? '0'.$dy : $dy; $mysqlFormat = "$y-$m-$dy"; $av=$mysqlFormat; } //Check for price. if($_POST['price']) { $p= escape_data($_POST['price']); } else{ $p = FALSE; echo '<p><font color="red" size="+1">Please enter Sale Price!</font></p>'; } //Check for offers. if($_POST['offers']) { $o= escape_data($_POST['offers']); } else{ $o = FALSE; echo '<p><font color="red" size="+1">Please indicate whether you will take offers!</font></p>'; } //Check for trustees. if($_POST['trustees']) { $t= escape_data($_POST['trustees']); } else{ $t = FALSE; echo '<p><font color="red" size="+1">Please enter your trustees name!</font></p>'; } //Check for property description. if($_POST['description']) { $d= escape_data($_POST['description']); } else{ $d = FALSE; echo '<p><font color="red" size="+1">Please describe your property!</font></p>'; } if ($rc && $rn && $ct && $rg && $tp && $un && $ft && $ow && $cl && $oc && $bk && $av && $p && $o && $t && $d) { //If everything OK $v=$_SESSION['user_id']; //add the property $query = "INSERT INTO property (v_id,rci_ref,country,region,resort_name,unit_desc,unit_num,floor_type,ownership,floating, occ_wk,booked,available,price,offers,trustees,description) VALUES ($v,$rc,'$ct','$rg','$rn','$tp','$un','$ft','$ow','$cl','$oc','$bk','$av','$p','$o','$t','$d')"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); if (mysql_affected_rows() == 1) { // If it ran OK. //log the advertisement //get last property_id $property_id = mysql_insert_id(); $query = "INSERT INTO ads VALUES ('','$u',NOW(),'','','$property_id')"; $result = mysql_query ($query) or die(mysql_error()); // $result = mysql_query($query); if (!mysql_affected_rows() == 1) { echo "Your Property could not be registered due to a system error.Please contact admin@homeownersdirect"; exit(); } //if it ran ok //update property record with ad ref $ad_ref = mysql_insert_id(); $query = "UPDATE property SET ad_ref ='$ad_ref' WHERE property_id = '$property_id'"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); $result = mysql_query($query); if (!$result) { echo "Your Property could not be registered due to a system error.Please contact admin@homeownersdirect"; exit(); } // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/Prop_payment.php'; ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); }else{ echo "Your Property could not be registered due to a system error.Please contact admin@homeownersdirect"; exit(); } } else { // If one of the data tests failed. echo '<p><font color="red" size="+1">Please try again.</font></p>'; } mysql_close(); // Close the database connection. } // End of the main Submit conditional. ?> <h1>Register Your Timeshare</h1> <form action="js.php" method="post"> <fieldset> <legend>RCI Reference Detail</legend> <p> <label for="rci_ref">RCI Reference:<em class="required">(required - numeric)</em></label> <input type="text" name="rci_ref" size="10" maxlength="10" value="<?php if (isset($_POST['rci_ref'])) echo $_POST['rci_ref']; ?>" /></p> <p> <label for="resort_name">Resort Name:</label> <input type="text" name="resort_name" size="35" maxlength="30" value="<?php if (isset($_POST['resort_name'])) echo $_POST['resort_name']; ?>" /></p> <p>Need to select country and Region from drop down list</p> <p> <label for="country">Country:</label> <select name="country" id="country" onchange="setRegions();"> <?php //Create the country select list foreach ($countries as $country) { echo "<option value=\"$country\"".(($country==$countrySel)?' selected':'').">$country</option>"; } ?> </select> <p> <label for="region">Region of Country:</label> <select name="region" id="region"> <?php //Create the region select list foreach ($regions as $region) { echo "<option value=\"$region\"".(($region==$regionSel)?' selected':'').">$region</option>"; } ?> </select> </fieldset> <fieldset> <legend>Unit Details</legend> <p> <label for="select">Please select your unit type</label> <select name="type"> <option value="No selection" <?php if(!$_POST || $_POST['type']== 'No selection') { ?>selected="selected" <?php }?> >Select one</option> <option value="T0">Studio</option> <option value="T1">1 Bed</option> <option value="T2">2 Bed</option> <option value="T3">Other</option> </select> </p> <p> <label for="unit_num">Unit Number:</label> <input type="text" name="unit_num" size="10" maxlength="6" value="<?php if (isset($_POST['unit_num'])) echo $_POST['unit_num']; ?>" /></p> <p> <label for="select">Please select your unit type</label> <select name="floor_type"> <option value="No selection" <?php if(!$_POST || $_POST['type']== 'No selection') { ?>selected="selected" <?php }?> >Select one</option> <option value="ground">Ground</option> <option value="first">First</option> <option value="second">Second</option> <option value="third">Third</option> </select> </p> <p> <label for="ownership">Please select your ownership type</label> <select name="ownership"> <option value="No selection" <?php if(!$_POST || $_POST['ownership']== 'No selection') { ?>selected="selected" <?php }?> >Select one</option> <option value="floating">Floating</option> <option value="fixed">Fixed</option> </select> </p> <p> <label for="color">If Floating ownership indicate period</label> <select name="color"> <option value="No selection" <?php if(!$_POST || $_POST['color']== 'No selection') { ?>selected="selected" <?php }?> >Select one</option> <option value="red">RED</option> <option value="blue">Blue</option> <option value="white">White</option> <option value="other">Other</option> </select> </p> <p> <label for="occ_wk">If Fixed please enter week:</label> <input type="text" name="occ_wk" size="10" maxlength="6" value="<?php if (isset($_POST['occ_wk'])) echo $_POST['occ_wk']; ?>" /></p> <p> <label for="select">Please indicate whether week is booked.</label> <select name="booked"> <option value="No selection" <?php if(!$_POST || $_POST['booked']== 'No selection') { ?>selected="selected" <?php }?> >Select one</option> <option value="yes">Yes</option> <option value="no">No</option> </select> </p> <p> <b>When will it be available for Sale?</b><em class="required">(MM/DD/YYYY)</em> </p> <p> <?php // This script makes three pull-down menus for an HTML form: months, days, years. // Make the months array. $month = array (1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); // Make the months pull-down menu. echo '<select name="month">'; foreach ($month as $key => $value) { echo "<option value=\"$key\">$value</option>\n"; } echo '</select>'; // Make the days pull-down menu. echo '<select name="day">'; for ($day = 1; $day <= 31; $day++) { echo "<option value=\"$day\">$day</option>\n"; } echo '</select>'; // Make the years pull-down menu. echo '<select name="year">'; $year = 2007; while ($year <= 2015) { echo "<option value=\"$year\">$year</option>\n"; $year++; } echo '</select>'; ?> </fieldset> <fieldset> <legend>Commercial Details</legend> <p> <label for="price">What is your asking price?</label> <input type="text" name="price" size="10" maxlength="6" value="<?php if (isset($_POST['price'])) echo $_POST['price']; ?>" /></p> <p> <label for="offers">Please indicate whether you will consider offers.</label> <select name="offers"> <option value="No selection" <?php if(!$_POST || $_POST['offers']== 'No selection') { ?>selected="selected" <?php }?> >Select one</option> <option value="yes">Yes</option> <option value="no">No</option> </select> </p> <p> <label for="trustees">Who are your Trustees?</label> <input type="text" name="trustees" size="35" maxlength="30" value="<?php if (isset($_POST['trustees'])) echo $_POST['trustees']; ?>" /></p> <p> <label for="description">Description:</label> <textarea name="description" id="description" cols="50" rows="10"> </textarea> </p> <div align="center"><input type="submit" name="submit" value="submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> </fieldset> </form> <?php // Include the HTML footer. include ('./includes/footer.html'); ?> header with js [code] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict. dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Timeshare1</title> <style type="text/css" media="screen">@import "./includes/layout.css";</style> <style type="text/css" media="screen">@import "./includes/full.css";</style> <!--[if lte IE 6] <style type="text/css" media="screen">@import "./includes/flyout_ie.css";</style> <![endif]--> </head> <script type="text/javascript"> // Region lists var regions = new Array(); <?php foreach ($regionList as $country => $regions) { echo "regions['$country'] = new Array ('" . implode("', '", $regions) . ",);\n"; } ?> function setRegions(){ cntrySel = document.getElementById('country'); regionSel = document.getElementById('region'); regionList = regions[cntrySel.value]; changeSelect(regionSel, regionList); } //**************************************************************************// // FUNCTION changeSelect(fieldObj, valuesAry, [optTextAry], [selectedVal]) // //**************************************************************************// function changeSelect(fieldObj, valuesAry, optTextAry, selectedValue) { //Clear the select list fieldObj.options.length = 0; //Set the option text to the values if not passed optTextAry = (optTextAry)?optTextAry:valuesAry; //Itterate through the list and create the options for (i in valuesAry) { selectFlag = (selectedValue && selectedValue==valuesAry[i])?true:false; fieldObj.options[fieldObj.length] = new Option(optTextAry[i], valuesAry[i], false, selectFlag); } } </script> </head> <body onload="setRegions();"> <div id="wrapper"> <div id="branding"> <img border="0" src="images/banner.gif" width="800" height="120" alt="Holiday Owners Direct"/> </div><!--End Branding--> <div id="content"> <div id="logo"> <h1 id="title">Home Owners Direct</h1> <div id="search"> <?php if (isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'logout.php')) { $name=$_SESSION['first_name']; echo "$name you are logged in"; }else{ echo "You have not logged in"; } ?> </div> <div class="float-divider"></div> </div> <div id="postheader"> <?php $currentPage = basename($_SERVER['SCRIPT_NAME']);?> <p class="breadcrumbs"><a href="index.php">Home</a> >> <?php echo"$currentPage";?></p> <p class="post-msg"><a href="view_browse_list.php">view browse list</a></p> <div class="float-divider"></div> </div> <p> <span class="hr border"></span>
[/code]
-
Many thanks Mjdamato.
I will try this and let you know the outcome.
I see the logic of what you say.
Thanks again and yes the js was in the include file.
-
This is the whole page.
<?php #register property session_start(); // Include the configuration file for error management and such. require_once ('./includes/config.inc.php'); // Set the page title and include the HTML header. $page_title = 'Register a Property'; include ('./includes/header_js.htm'); $u= $_SESSION['user_id']; // Handle the form. if (isset($_POST['submitted'])) { require_once ('./mysql_connect2.php'); // Connect to the database. //check for rci reference if(isset($_POST['rci_ref']) && is_numeric($_POST['rci_ref'])) { $rc= escape_data($_POST['rci_ref']); } else{ $rc = FALSE; echo '<p><font color="red" size="+1">Please enter rci reference. Must be Numeric!</font></p>'; } //check for resort name if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['resort_name'])))) { $rn = escape_data($_POST['resort_name']); } else { $rn = FALSE; echo '<p><font color="red" size="+1">Please enter resort name!</font></p>'; } //check for Country if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['country'])))) { $ct = escape_data($_POST['country']); } else { $ct = FALSE; echo '<p><font color="red" size="+1">Please enter Country!</font></p>'; } //check for Region if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['region'])))) { $rg = escape_data($_POST['region']); } else { $rg = FALSE; echo '<p><font color="red" size="+1">Please enter region of the country!</font></p>'; } //Check type of accommodation. if($_POST['type']) { $tp= escape_data($_POST['type']); } else{ $tp = FALSE; echo '<p><font color="red" size="+1">Please select your unit type!</font></p>'; } //Check for unit number. if($_POST['unit_num']) { $un= escape_data($_POST['unit_num']); } else{ $un = FALSE; echo '<p><font color="red" size="+1">Please enter your unit number!</font></p>'; } //Check floor type. if($_POST['floor_type']) { $ft= escape_data($_POST['floor_type']); } else{ $ft= FALSE; echo '<p><font color="red" size="+1">Please select your floor type!</font></p>'; } //Check type of ownership. if($_POST['ownership']) { $ow= escape_data($_POST['ownership']); } else{ $ow = FALSE; echo '<p><font color="red" size="+1">Please select your ownership type!</font></p>'; } //Check type of period eg red, blue, etc. if($_POST['color']) { $cl= escape_data($_POST['color']); } else{ $cl = FALSE; echo '<p><font color="red" size="+1">Please indicate your period color!</font></p>'; } //Check for occupation week. if($_POST['occ_wk']) { $oc= escape_data($_POST['occ_wk']); } else{ $oc = FALSE; echo '<p><font color="red" size="+1">Please select your unit type!</font></p>'; } //Check type of booked weeks. if($_POST['booked']) { $bk= escape_data($_POST['booked']); } else{ $bk = FALSE; echo '<p><font color="red" size="+1">Please confirm if week booked or not!</font></p>'; } //Check availability for sale. if($_POST['month']) { $m= escape_data($_POST['month']); } else{ $m = FALSE; echo '<p><font color="red" size="+1">Please enter month!</font></p>'; } //Check availability for sale. if($_POST['day']) { $dy= escape_data($_POST['day']); } else{ $dy = FALSE; echo '<p><font color="red" size="+1">Please enter day of month!</font></p>'; } //Check availability for sale. if($_POST['year']) { $y= escape_data($_POST['year']); } else{ $y = FALSE; echo '<p><font color="red" size="+1">Please enter year!</font></p>'; } if (!checkdate($m,$dy,$y)) { $error = 'You have used an invalid date'; } else { $dy = $dy < 10 ? '0'.$dy : $dy; $mysqlFormat = "$y-$m-$dy"; $av=$mysqlFormat; } //Check for price. if($_POST['price']) { $p= escape_data($_POST['price']); } else{ $p = FALSE; echo '<p><font color="red" size="+1">Please enter Sale Price!</font></p>'; } //Check for offers. if($_POST['offers']) { $o= escape_data($_POST['offers']); } else{ $o = FALSE; echo '<p><font color="red" size="+1">Please indicate whether you will take offers!</font></p>'; } //Check for trustees. if($_POST['trustees']) { $t= escape_data($_POST['trustees']); } else{ $t = FALSE; echo '<p><font color="red" size="+1">Please enter your trustees name!</font></p>'; } //Check for property description. if($_POST['description']) { $d= escape_data($_POST['description']); } else{ $d = FALSE; echo '<p><font color="red" size="+1">Please describe your property!</font></p>'; } if ($rc && $rn && $ct && $rg && $tp && $un && $ft && $ow && $cl && $oc && $bk && $av && $p && $o && $t && $d) { //If everything OK $v=$_SESSION['user_id']; //add the property $query = "INSERT INTO property (v_id,rci_ref,country,region,resort_name,unit_desc,unit_num,floor_type,ownership,floating, occ_wk,booked,available,price,offers,trustees,description) VALUES ($v,$rc,'$ct','$rg','$rn','$tp','$un','$ft','$ow','$cl','$oc','$bk','$av','$p','$o','$t','$d')"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); if (mysql_affected_rows() == 1) { // If it ran OK. //log the advertisement //get last property_id $property_id = mysql_insert_id(); $query = "INSERT INTO ads VALUES ('','$u',NOW(),'','','$property_id')"; $result = mysql_query ($query) or die(mysql_error()); // $result = mysql_query($query); if (!mysql_affected_rows() == 1) { echo "Your Property could not be registered due to a system error.Please contact admin@homeownersdirect"; exit(); } //if it ran ok //update property record with ad ref $ad_ref = mysql_insert_id(); $query = "UPDATE property SET ad_ref ='$ad_ref' WHERE property_id = '$property_id'"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); $result = mysql_query($query); if (!$result) { echo "Your Property could not be registered due to a system error.Please contact admin@homeownersdirect"; exit(); } // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/Prop_payment.php'; ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); }else{ echo "Your Property could not be registered due to a system error.Please contact admin@homeownersdirect"; exit(); } } else { // If one of the data tests failed. echo '<p><font color="red" size="+1">Please try again.</font></p>'; } mysql_close(); // Close the database connection. } // End of the main Submit conditional. ?> <h1>Register Your Timeshare</h1> <form action="js.php" method="post"> <fieldset> <legend>RCI Reference Detail</legend> <p> <label for="rci_ref">RCI Reference:<em class="required">(required - numeric)</em></label> <input type="text" name="rci_ref" size="10" maxlength="10" value="<?php if (isset($_POST['rci_ref'])) echo $_POST['rci_ref']; ?>" /></p> <p> <label for="resort_name">Resort Name:</label> <input type="text" name="resort_name" size="35" maxlength="30" value="<?php if (isset($_POST['resort_name'])) echo $_POST['resort_name']; ?>" /></p> <p>Need to select country and Region from drop down list</p> <p> <label for="country">Country:</label> <select name="country" id="country" onchange="setRegions();"> <option value="Spain"<?php if ($_POST['country']=='Spain') echo ' selected'; ?>>Spain</option> <option value="France"<?php if ($_POST['country']=='France') echo ' selected'; ?>>France</option> <option value="United States"<?php if ($_POST['country']=='United States') echo ' selected'; ?>>United States</option> </select> <p> <label for="region">Region of Country:</label> <select name="region" id="region"></select> </fieldset> <fieldset> <legend>Unit Details</legend> <p> <label for="select">Please select your unit type</label> <select name="type"> <option value="No selection" <?php if(!$_POST || $_POST['type']== 'No selection') { ?>selected="selected" <?php }?> >Select one</option> <option value="T0">Studio</option> <option value="T1">1 Bed</option> <option value="T2">2 Bed</option> <option value="T3">Other</option> </select> </p> <p> <label for="unit_num">Unit Number:</label> <input type="text" name="unit_num" size="10" maxlength="6" value="<?php if (isset($_POST['unit_num'])) echo $_POST['unit_num']; ?>" /></p> <p> <label for="select">Please select your unit type</label> <select name="floor_type"> <option value="No selection" <?php if(!$_POST || $_POST['type']== 'No selection') { ?>selected="selected" <?php }?> >Select one</option> <option value="ground">Ground</option> <option value="first">First</option> <option value="second">Second</option> <option value="third">Third</option> </select> </p> <p> <label for="ownership">Please select your ownership type</label> <select name="ownership"> <option value="No selection" <?php if(!$_POST || $_POST['ownership']== 'No selection') { ?>selected="selected" <?php }?> >Select one</option> <option value="floating">Floating</option> <option value="fixed">Fixed</option> </select> </p> <p> <label for="color">If Floating ownership indicate period</label> <select name="color"> <option value="No selection" <?php if(!$_POST || $_POST['color']== 'No selection') { ?>selected="selected" <?php }?> >Select one</option> <option value="red">RED</option> <option value="blue">Blue</option> <option value="white">White</option> <option value="other">Other</option> </select> </p> <p> <label for="occ_wk">If Fixed please enter week:</label> <input type="text" name="occ_wk" size="10" maxlength="6" value="<?php if (isset($_POST['occ_wk'])) echo $_POST['occ_wk']; ?>" /></p> <p> <label for="select">Please indicate whether week is booked.</label> <select name="booked"> <option value="No selection" <?php if(!$_POST || $_POST['booked']== 'No selection') { ?>selected="selected" <?php }?> >Select one</option> <option value="yes">Yes</option> <option value="no">No</option> </select> </p> <p> <b>When will it be available for Sale?</b><em class="required">(MM/DD/YYYY)</em> </p> <p> <?php // This script makes three pull-down menus for an HTML form: months, days, years. // Make the months array. $month = array (1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); // Make the months pull-down menu. echo '<select name="month">'; foreach ($month as $key => $value) { echo "<option value=\"$key\">$value</option>\n"; } echo '</select>'; // Make the days pull-down menu. echo '<select name="day">'; for ($day = 1; $day <= 31; $day++) { echo "<option value=\"$day\">$day</option>\n"; } echo '</select>'; // Make the years pull-down menu. echo '<select name="year">'; $year = 2007; while ($year <= 2015) { echo "<option value=\"$year\">$year</option>\n"; $year++; } echo '</select>'; ?> </fieldset> <fieldset> <legend>Commercial Details</legend> <p> <label for="price">What is your asking price?</label> <input type="text" name="price" size="10" maxlength="6" value="<?php if (isset($_POST['price'])) echo $_POST['price']; ?>" /></p> <p> <label for="offers">Please indicate whether you will consider offers.</label> <select name="offers"> <option value="No selection" <?php if(!$_POST || $_POST['offers']== 'No selection') { ?>selected="selected" <?php }?> >Select one</option> <option value="yes">Yes</option> <option value="no">No</option> </select> </p> <p> <label for="trustees">Who are your Trustees?</label> <input type="text" name="trustees" size="35" maxlength="30" value="<?php if (isset($_POST['trustees'])) echo $_POST['trustees']; ?>" /></p> <p> <label for="description">Description:</label> <textarea name="description" id="description" cols="50" rows="10"> </textarea> </p> <div align="center"><input type="submit" name="submit" value="submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> </fieldset> </form> <?php // Include the HTML footer. include ('./includes/footer.html'); ?>
-
Hi mjdamato
I forgot the html output.
The erros in the script is
Line 27
Char 1
Error: Object required
Code 0
Url:.....js.php
This also causes the query on the db to fail with
Column Count doesnt match count at row 1.
Which i guess means we dont have avalue for country.
-
I follow what you are saying but cant spot the problem.
I have provided below the code. I am afraid its rather full, but its the complete job.
I put the js in my header and added the rest to my main form and validation.
The error is:-
An error occurred.........\js.php on line 320: Undefined index:country Date/Time..>Spain
Repeated for 321 >France and >322 United States.
The header is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict. dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Timeshare1</title> <style type="text/css" media="screen">@import "./includes/layout.css";</style> <style type="text/css" media="screen">@import "./includes/full.css";</style> <!--[if lte IE 6] <style type="text/css" media="screen">@import "./includes/flyout_ie.css";</style> <![endif]--> </head> <script type="text/javascript"> // Region lists var regions = new Array(); regions['Spain'] = new Array('Almeria', 'Costa del Sol'); regions['France'] = new Array('Midi-Pyrenees', 'Languedoc-Roussillon','Aquitane'); regions['United States'] = new Array('Arizona','Florida'); function setRegions(){ cntrySel = document.getElementById('country'); regionSel = document.getElementById('region'); regionList = regions[cntrySel.value]; changeSelect(regionSel, regionList); } //**************************************************************************// // FUNCTION changeSelect(fieldObj, valuesAry, [optTextAry], [selectedVal]) // //**************************************************************************// function changeSelect(fieldObj, valuesAry, optTextAry, selectedValue) { //Clear the select list fieldObj.options.length = 0; //Set the option text to the values if not passed optTextAry = (optTextAry)?optTextAry:valuesAry; //Itterate through the list and create the options for (i in valuesAry) { selectFlag = (selectedValue && selectedValue==valuesAry[i])?true:false; fieldObj.options[fieldObj.length] = new Option(optTextAry[i], valuesAry[i], false, selectFlag); } } </script> </head> <body onload="setRegions();"> <div id="wrapper"> <div id="branding"> <img border="0" src="images/banner.gif" width="800" height="120" alt="Holiday Owners Direct"/> </div><!--End Branding--> <div id="content"> <div id="logo"> <h1 id="title">Home Owners Direct</h1> <div id="search"> <?php if (isset($_SESSION['user_id']) AND (substr($_SERVER['PHP_SELF'], -10) != 'logout.php')) { $name=$_SESSION['first_name']; echo "$name you are logged in"; }else{ echo "You have not logged in"; } ?> </div> <div class="float-divider"></div> </div> <div id="postheader"> <?php $currentPage = basename($_SERVER['SCRIPT_NAME']);?> <p class="breadcrumbs"><a href="index.php">Home</a> >> <?php echo"$currentPage";?></p> <p class="post-msg"><a href="view_browse_list.php">view browse list</a></p> <div class="float-divider"></div> </div> <p> <span class="hr border"></span>
The first part of the form
<h1>Register Your Timeshare</h1> <form action="js.php" method="post"> <fieldset> <legend>RCI Reference Detail</legend> <p> <label for="rci_ref">RCI Reference:<em class="required">(required - numeric)</em></label> <input type="text" name="rci_ref" size="10" maxlength="10" value="<?php if (isset($_POST['rci_ref'])) echo $_POST['rci_ref']; ?>" /></p> <p> <label for="resort_name">Resort Name:</label> <input type="text" name="resort_name" size="35" maxlength="30" value="<?php if (isset($_POST['resort_name'])) echo $_POST['resort_name']; ?>" /></p> <p>Need to select country and Region from drop down list</p> <p> <label for="country">Country:</label> <select name="country" id="country" onchange="setRegions();"> <option value="Spain"<?php if ($_POST['country']=='Spain') echo ' selected'; ?>>Spain</option> <option value="France"<?php if ($_POST['country']=='France') echo ' selected'; ?>>France</option> <option value="United States"<?php if ($_POST['country']=='United States') echo ' selected'; ?>>United States</option> </select> <p> <label for="region">Region of Country:</label> <select name="region" id="region"></select> </fieldset> The first part of the validation [code] // Handle the form. if (isset($_POST['submitted'])) { require_once ('./mysql_connect2.php'); // Connect to the database. //check for rci reference if(isset($_POST['rci_ref']) && is_numeric($_POST['rci_ref'])) { $rc= escape_data($_POST['rci_ref']); } else{ $rc = FALSE; echo '<p><font color="red" size="+1">Please enter rci reference. Must be Numeric!</font></p>'; } //check for resort name if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['resort_name'])))) { $rn = escape_data($_POST['resort_name']); } else { $rn = FALSE; echo '<p><font color="red" size="+1">Please enter resort name!</font></p>'; } //check for Country if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['country'])))) { $ct = escape_data($_POST['country']); } else { $ct = FALSE; echo '<p><font color="red" size="+1">Please enter Country!</font></p>'; } //check for Region if (eregi ('^[[:alpha:]\.\' \-]{2,15}$', stripslashes(trim($_POST['region'])))) { $rg = escape_data($_POST['region']); } else { $rg = FALSE; echo '<p><font color="red" size="+1">Please enter region of the country!</font></p>'; }
[/code]
Thanks for your interest.
-
hi mjdamato,
I have incorporated the js example but I get an error
'undefined index country'
Does the example store the country selection as post data as well as the region?
I need both country and region in the post data.
Sorry to bother you but I dont know js and I cant quite understand the effect of this line of code:
<select name="country" id="country" onchange="setRegions();">
Any advice appreciated.
-
Thanks for coming back. I will study this to properly follow it.
-
Yes,sorry I did mean javascript although i am not familiar with it.
Thank you for the example I will try and get to grips with it.
My initial question is how are values passed in this way? As with Post and Get?
The form also indicates selecting country value twice when I would have expected state/city in the example.
I will investigate.
Thanks again
-
I have gone for the java option but I am not sure how to capture the 2 values, country and region in the code I have.
If I submit the form to same page and I want to validate the 2 values and then show the rest of the form.
Here is the code
<SCRIPT language=JavaScript> function reload(form) { // Setting the variable with the value of selected country's ID var val=populate.countryList.options[populate.countryList.options.selectedIndex].value; // Sending the country id in the query string to retrieve the city list self.location='drop.php?countryId=' + val ; } </script> <? /* - Function to return the Country list as an array */ function getCountryList() { // Country List array $countryList = array ( '1'=> 'Spain', '2'=> 'France', '3'=> 'United States', ); return $countryList; return $countryList; } /* - Function to return the City list as an array - Country ID is used to generate the city list */ function getCityList($countryId) { // City list array // First key of the array is the Country ID, which holds an array of City list $cityList = array ( '1'=> array ('Almeria', 'Costa del Sol'), '2'=> array ('Midi-Pyrenees', 'Languedoc-Roussillon','Aquitane'), '3'=> array ('Arizona','Florida') ); return $cityList[$countryId]; } ?> <form action="drop.php" name="populate"> <fieldset> <legend>Enter Country</legend> <p> <label for="country">Country:</label> <? // Retrieving the country list $countryList = getCountryList(); // Setting the variable if the country is selected for its city list @$countryId = $_GET['countryId']; // Retrieving the city list if a country is selected $cityList = ($countryId) ? getCityList($countryId) : null; if (!empty($countryList)) { // Generating the country drop down menu echo "<select onChange='reload(this.form)' name='countryList'>"; foreach ($countryList as $key => $value) { echo "<option value='$key'"; if ($countryId == $key) echo "selected"; echo ">$value</option>"; } echo "</select>"; } if (!empty($cityList)) { // Generating the city drop down menu if a country is selected echo "<select name='cityList'>"; foreach ($cityList as $key => $value) { echo "<option value='$key'>$value</option>"; } echo "</select>\n"; } ?> //need to capture both values. </p> <div align="center"><input type="submit" name="submit" value="submit" /></div> <input type="hidden" name="submitted" value="TRUE" /> </fieldset> </form>
-
Thanks for that. I will think it through.
-
I have developed a form to register a property in a db.
The form needs the selection of a country and then based on that selection the selection of regions from the selected country.
I have a program which allows selection of a country and then a region but it uses java script which I would like to avoid. I also just wanted one submit button if possible.
Does anyone have an idea of how to approach this please?
The reristration form is structured thus
//Check form submitted and validate POST entries
//update db
//redirect
// Display form
//show errors and valid entries for correction
//submit form
This is the first part of the registration form that I need to make the selection in.
<h1>Register Your Timeshare</h1> <form action="reg_property.php" method="post"> <fieldset> <legend>RCI Reference Detail</legend> <p> <label for="rci_ref">RCI Reference:<em class="required">(required - numeric)</em></label> <input type="text" name="rci_ref" size="10" maxlength="10" value="<?php if (isset($_POST['rci_ref'])) echo $_POST['rci_ref']; ?>" /></p> <p> <label for="resort_name">Resort Name:</label> <input type="text" name="resort_name" size="35" maxlength="30" value="<?php if (isset($_POST['resort_name'])) echo $_POST['resort_name']; ?>" /></p> //Need to select country and Region from drop down list <p> <label for="country">Country:</label> <input type="text" name="country" size="35" maxlength="30" value="<?php if (isset($_POST['country'])) echo $_POST['country']; ?>" /></p> <p> <label for="region">Region of Country:</label> <input type="text" name="region" size="35" maxlength="30" value="<?php if (isset($_POST['region'])) echo $_POST['region']; ?>" /></p> </fieldset>
The populate program which allows the selection of the country and the regions is as follows:
<SCRIPT language=JavaScript> function reload(form) { // Setting the variable with the value of selected country's ID var val=populate.countryList.options[populate.countryList.options.selectedIndex].value; // Sending the country id in the query string to retrieve the city list self.location='populate.php?countryId=' + val ; } </script> <? /* - Function to return the Country list as an array */ function getCountryList() { // Country List array $countryList = array ( '1'=> 'Spain', '2'=> 'France', '3'=> 'United States', ); return $countryList; return $countryList; } /* - Function to return the City list as an array - Country ID is used to generate the city list */ function getCityList($countryId) { // City list array // First key of the array is the Country ID, which holds an array of City list $cityList = array ( '1'=> array ('Almeria', 'Costa del Sol'), '2'=> array ('Midi-Pyrenees', 'Languedoc-Roussillon','Aquitane'), '3'=> array ('Arizona','Florida') ); return $cityList[$countryId]; } ?> <form action="populate.php" name="populate"> <? // Retrieving the country list $countryList = getCountryList(); // Setting the variable if the country is selected for its city list @$countryId = $_GET['countryId']; // Retrieving the city list if a country is selected $cityList = ($countryId) ? getCityList($countryId) : null; if (!empty($countryList)) { // Generating the country drop down menu echo "<select onChange='reload(this.form)' name='countryList'>"; foreach ($countryList as $key => $value) { echo "<option value='$key'"; if ($countryId == $key) echo "selected"; echo ">$value</option>"; } echo "</select>"; } if (!empty($cityList)) { // Generating the city drop down menu if a country is selected echo "<select name='cityList'>"; foreach ($cityList as $key => $value) { echo "<option value='$key'>$value</option>"; } echo "</select>"; } ?> </form>
-
Many thanks. Thats the problem. I couldn't see the woods for the trees.
Cheers
-
i ahve a form which records into 2 tables property and ads.
the update to the ads table produces 2 records not 1.
I cant fathom why. Can anyone help please.
The query is 'INSERT INTO ads' half way down.
if ($rc && $rn && $tp && $un && $ft && $ow && $cl && $oc && $bk && $av && $p && $o && $t && $d) { //If everything OK $v=$_SESSION['user_id']; //add the property $query = "INSERT INTO property (v_id,rci_ref,resort_name,unit_desc,unit_num,floor_type,ownership,floating, occ_wk,booked,available,price,offers,trustees,description) VALUES ($v,$rc,'$rn','$tp','$un','$ft','$ow','$cl','$oc','$bk','$av','$p','$o','$t','$d')"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); if (mysql_affected_rows() == 1) { // If it ran OK. //log the advertisement //get last property_id $property_id = mysql_insert_id(); //This causes 2 records to be added to ads $query = "INSERT INTO ads VALUES ('','$u',NOW(),'','','$property_id')"; $result = mysql_query ($query) or die(mysql_error()); $result = mysql_query($query); if (!$result) { echo "Your Property could not be registered due to a system error.Please contact admin@homeownersdirect"; exit(); } //if it ran ok //update property record with ad ref $ad_ref = mysql_insert_id(); $query = "UPDATE property SET ad_ref ='$ad_ref' WHERE property_id = '$property_id'"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); $result = mysql_query($query); if (!$result) { echo "Your Property could not be registered due to a system error.Please contact admin@homeownersdirect"; exit(); }
-
Thanks both.
i dont have a link its localhost.
server is runing.
I wil check the other things and get back.
-
hi Thanks
PHP is working fine with other programs in the application and with other applications.
The file has a .php ext.
looking at view source the whole code is viewable but not with any other programs.
I dont know where to go from here?
-
i have an upload program which displays the phpcode.
I can't find the error.can some one spot the obvious?Thanks.
the code is diplayed from here (italised) lines 29 to 59.
// check that file is within the permitted size if ($_FILES['image']['size'] >[i]0 && $_FILES['image']['size'] <= MAX_FILE_SIZE) { $sizeOK = true; }[/i]
The code is
<?php require_once ('./includes/config.inc.php'); require_once ('ts_fns.php') ; // Set the page title and include the HTML header. include('includes/title.inc.php'); include ('./includes/header.html'); // session start session_start(); // define a constant for the maximum upload size define ('MAX_FILE_SIZE', 51200); if (array_key_exists('upload', $_POST)) { // define constant for upload folder define('UPLOAD_DIR', 'C:/upload_test/'); // replace any spaces in original filename with underscores // at the same time, assign to a simpler variable $file = str_replace(' ', '_', $_FILES['image']['name']); // convert the maximum size to KB $max = number_format(MAX_FILE_SIZE/1024, 1).'KB'; // create an array of permitted MIME types $permitted = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/png'); // begin by assuming the file is unacceptable $sizeOK = false; $typeOK = false; // check that file is within the permitted size if ($_FILES['image']['size'] >0 && $_FILES['image']['size'] <= MAX_FILE_SIZE) { $sizeOK = true; } // check that file is of an permitted MIME type foreach ($permitted as $type) { if ($type == $_FILES['image']['type']) { $typeOK = true; break; } } if ($sizeOK && $typeOK) { switch($_FILES['image']['error']) { case 0: include('./includes/create_thumb.inc.php'); break; case 3: $result = "Error uploading $file. Please try again."; default: $result = "System error uploading $file. Contact webmaster."; } } elseif ($_FILES['image']['error'] == 4) { $result = 'No file selected'; } else { $result = "$file cannot be uploaded. Maximum size: $max. Acceptable file types: gif, jpg, png."; } } ?> <form action="" method="post" enctype="multipart/form-data" name="uploadImage" id="uploadImage"> <fieldset> <legend>Upload images for your timeshare</legend> <p> <label for="image">Upload image:<em class="required">(only jpg,gif,png.Max size 50Kb)</em></label> <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo MAX_FILE_SIZE; ?>" /> <input type="file" name="image" id="image" /> </p> <p> <input type="submit" name="upload" id="upload" value="Upload" /> </p></fieldset> </form> <?php include ('./includes/footer.html'); exit(); ?>
-
thanks. No errors but no results returned.It goes to my else condition so something wrong somwhere as there are records to retrieve.
I will investigate and give you a rest
thanks
Column count error
in MySQL Help
Posted
I have an input form with a number of variables.
When I try to insert the values I get an error 'Column count doesnt match value count at row 1'
I use the format INSERT INTO table (cols1,2,..) VALUES ('Value1',' Value2',)
The first column in the table is the primary which is auto increment.
The intial table structure is
property_id
V_id
rci_ref
country
region etc
Only the cols I am inserting are referenced in the query.
Where am I going wrong. How do I debug this?