Jump to content

herschen

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

herschen's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm using the following code, but can't identify why the variable $usage, $_POST['usage'], or the usage field in my mysql database causes problems. If I take out usage, everything works fine. Any other combination of fields (when usage is included) gives me the error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'usage, package, comment. Usage is a varchar field with 100 characters (the same as all the other fields) and $_POST['usage'] is a text field that contains the year '2010', '2011', etc. Here's the code: $date = date('Y-m-d'); $typeofinquiry = $_POST['typeofinquiry']; $name = $_POST['name']; $email = $_POST['email']; $phone = $_POST['phone']; $propertyid = $_POST['id']; $bldg = $_POST['bldg']; $size = $_POST['size']; $usage = $_POST['usage']; $package = $_POST['multiples']; $comments = $_POST['comments']; if ($clientemailexist == 0) { $query = "INSERT INTO clients (date, typeofinquiry, name, email, phone, propertyid, bldg, size, usage, package, comments) VALUES ('$date', '$typeofinquiry', '$name', '$email', '$phone', '$propertyid', '$bldg', '$size', '$usage', '$package', '$comments')"; mysql_query($query) or die(mysql_error());
  2. This was an HTML error. For some reason, there was a huge gap between the end of the paragraph at the top and the table. Since I didn't repeat the end of the paragraph, the gap didn't show up on the subsequent repeats of the table. Thanks.
  3. Also, I just noticed that the top part of the table: <table width="100%" border="0" cellpadding="0" cellspacing="0" class="style1"> <tr> <td width="16%"><strong>Phone Number</strong></td> <td width="15%"><strong>Hours</strong></td> <td width="57%"><strong>Department</strong></td> </tr> doesn't display either. This is real odd. The other thing that is odd, is that I replaced the first row in the table with the statement "What the heck is going on?" This showed up, however the row with Phone Number, Hours and Dept. did not. Furthermore, in the following "repeats" the phone numbers display properly, but the statement "What the heck is going on?" shows up after those phone numbers (this is odd because as far as the html goes, that statement comes before the 2nd row, where all of the phone numbers are displayed.)
  4. I have figured out where the problem is ocurring, yet I still cannot figure out why. Maybe someone can help me. I put the echo $row_rsPhone['phonenumber']; right after the if parameters and it works fine if ($row_rsSubContact['subContact'] == $row_rsPhone['subContact']) { echo $row_rsPhone['phonenumber']; However, when I put that same code after the if parameters in a table row, it doesn't display. <?php do { ?> <tr> <td width="16%"><strong>Phone Number</strong></td> <td width="15%"><strong>Hours</strong></td> <td width="57%"><strong>Department</strong></td> </tr> <?php do { ?> <?php if ($row_rsSubContact['subContact'] == $row_rsPhone['subContact']) { echo $row_rsPhone['phonenumber']; ?> <br /> <tr> <td><?php echo $row_rsPhone['phonenumber']; ?></td> <td><?php echo $row_rsPhone['hours']; ?></td> <td><?php echo $row_rsPhone['dept']; ?></td> </tr> <?php } ?> <?php } while ($row_rsPhone = mysql_fetch_assoc($rsPhone)); ?> <?php mysql_data_seek($rsPhone,0); ?> <?php } while ($row_rsSubContact = mysql_fetch_assoc($rsSubContact)); ?> Keep in mind that this is only for the first time around in the repeat region. The rest of the times that the repeating region...repeats, it displays fine. I'm not understanding what makes that <td> field so intimidating for php or mysql. Thank you.
  5. I actually forgot to post what I have at the top of the page (I'm doing this in Dreamweaver): $colname_rsSubContact = "-1"; if (isset($_GET['contactname'])) { $colname_rsSublender = $_GET['contactname']; } mysql_select_db($database_contact, $contact); $query_rsSubContact = sprintf("SELECT * FROM subcontact WHERE contactname = %s", GetSQLValueString($colname_rsSubContact, "text")); $rsSubContact = mysql_query($query_rsSubContact, $contact) or die(mysql_error()); $row_rsSubContact = mysql_fetch_assoc($rsSubContact); $totalRows_rsSubContact = mysql_num_rows($rsSubContact); $colname_rsPhone = "-1"; if (isset($_GET['contactname'])) { $colname_rsLenders = $_GET['contactname']; } mysql_select_db($database_contact, $contact); $query_rsPhone= sprintf("SELECT * FROM phone WHERE contactname = %s", GetSQLValueString($colname_rsPhone, "text")); $rsPhone = mysql_query($query_rsPhone, $contact) or die(mysql_error()); $row_rsPhone = mysql_fetch_assoc($rsPhone); $totalRows_rsPhone = mysql_num_rows($rsPhone); I think that this is already calling the first record in the mysql database...right? Thanks for the quick response.
  6. I have created the following code and am tearing my hair out. I have a list of contact information for clients and some of them have multiple contact people within their organization. I've created several tables (phone, fax, email) and in each table I've included the field subcontact. I've also created a separate table subContacts, which contains the main contacts name along with the "subcontact" name. So I've made a repeating region that goes through the subContacts table and is filtered by the main contact name (through a URL parameter). Inside that repeating region, I go through each table with another repeating region that will display a phone number, email, address, etc. only when the subcontact fields match. At the end of this repeating region I use this code: <?php mysql_data_seek($rsPhone,0); ?> to reset this field for when the subContacts table comes around again (and now has a different subcontact name). Fax Numbers worked fine. However, when I tested phone numbers, the first subcontact would not display. I then ran a series of frustrating tests that verified to me that the two fields matched, but for some reason, on the first "repeat" the phone number would not display. The test I did was I replaced the table I had with the text "Go screw yourself royally" when the two fields matched. It worked flawlessly. I know the two fields are matching and the if then parameters are fine, what's wrong? If you need more information, please let me know. This is my first post in a while, so I more than likely forgot a key element. Here's the code I'm using (don't worry about the contacts that don't have subContacts...I've already handled that issue): <table width="100%" border="0" cellpadding="0" cellspacing="0" class="style1"> <tr> <td width="16%"><strong>Phone Number</strong></td> <td width="15%"><strong>Hours</strong></td> <td width="57%"><strong>Department</strong></td> </tr> <?php do { ?> <?php if ($row_rsSubContact['subContact'] == $row_rsPhone['subContact']) { echo 'Go screw yourself royally'; ?> <br /> <tr> <td><?php echo $row_rsPhone['phonenumber']; ?></td> <td><?php echo $row_rsPhone['hours']; ?></td> <td><?php echo $row_rsPhone['dept']; ?></td> </tr> <?php } ?> <?php } while ($row_rsPhone = mysql_fetch_assoc($rsPhone)); ?> <?php mysql_data_seek($rsPhone,0); ?> <br /> <br /> <?php } while ($row_rsSubContact = mysql_fetch_assoc($rsSubContact)); ?>
  7. I work equally as much on my home computer as I do on my office computer. I've gotten most of my documents on Google Docs, I have files on box.net. I would like to set up Apache so my "localhost" directory is some form of online storage mounted as a hard drive on my computer. I'm using Ubuntu Linux at home and Windows XP in my office. I've tried box.net with limited success. At home, Ubuntu was able to mount it as a filesystem, but only root could access it and when I did try to copy files there (as root) it would not let me. In Windows XP, I was able to install it as a network location, but it would not let me map it as a drive.
  8. Does anybody know anything...please respond, just a simple hello would let me know that someone is looking at this post.
  9. Does anyone have an idea of what might be the problem? Supposedly this script has worked great for a bunch of people: http://www.theblog.ca/?p=12
  10. I just ran the mysql query with the while loop, but I set it to only loop once ($i = 0; while ($i <= 0) {). This worked fine, updating picorder on the first row fine. I also tried changing it to while $i <= 2...this worked fine once, updating the first 3 entries successfully. Then I tried converting count($_POST['newpicorder'} to an integer with the convertToInt function and using the variable returned in the while loop. The resulting picorder entries were 4, 4, 4, 1, 2,1. Not what I wanted, but at least every instance of picorder is not 1. I tried using '5' and back to '2' in the while loop, and this didn't work a second time...I don't know why. Finally, I set the while loop to loop once and it worked again with flying colors. I really don't have the foggiest idea what is going wrong.
  11. Could you please clarify what you mean here? I have updated the query, so I am now inserting an integer into the database and I have converted picorder to int. It still changes every instance of picorder (only where propertyid=what I specified) to '1' when I do the while loop, but if I delete the while loop (and just edit the first listing) I have no problem. What could be wrong with the loop? This did not work with a for loop either. <?php function convertToInt($string) { $y = ltrim($string, '0'); $z = 0 + $y; return $z; } mysql_select_db($database); $size = count($_POST['newpicorder']); $i = 0; $id = $_POST['id'][$i]; $oldpicorder = $_POST['oldpicorder'][$i]; $newpicorder = convertToInt($_POST['newpicorder'][$i]); print_r($newpicorder); print "<br>"; $query = "UPDATE propertiesimages SET picorder ='$newpicorder' WHERE propertyid = '$id' AND picorder='$oldpicorder'"; mysql_query($query) or die (mysql_error()); print "$oldpicorder" . " updated to" . " $newpicorder". "<br />"; mysql_close(); ?>
  12. That unfortunately did not work. I got this message when I replaced my code with your code: Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\RealEstate\properties\update_process.php on line 16 I believe you need to have double-quotes on the outside and single-quotes on the inside of the mysql_query. Thanks for your prompt response.
  13. Everytime I try to update 'picorder' in the 'propertiesimages' table, picorder gets converted to 1. I'm using PHP 5.2.4, MySQL 5.0.45, and the table is InnoDB. 'propertyid' in table 'propertiesimages' is a foreign key to 'propertyid' in 'properties' Here's the code that should work (I got this code at http://www.theblog.ca/?p=12: Form: <?php $hostname = "localhost"; $database = "properties"; $username = "properties"; $password = "xxxxxxx"; mysql_connect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR); $colname_rsImages = "-1"; if (isset($_GET['propertyid'])) { $colname_rsImages = $_GET['propertyid']; } mysql_select_db($database); $result = mysql_query("SELECT * FROM propertiesimages WHERE propertyid = '$colname_rsImages' "); $i = 0; print "<form name='update_image' method='post' action='shit_process.php'>\n"; while ($images = mysql_fetch_array($result)) { print "<input type='hidden' name='id[$i]' value='{$images['propertyid']}' />"; print "<input type='hidden' name='oldpicorder[$i]' value='{$images['picorder']}' />"; print "<p>{$images['picorder']}: <input type='text' size='40' name='newpicorder[$i]' value='{$images['picorder']}' /></p>\n"; ++$i; } print "<input type='submit' value='submit' />"; print "</form>"; mysql_close(); ?> Script: <?php $hostname = "localhost"; $database = "properties"; $username = "properties"; $password = "xxxxxxx"; mysql_connect($hostname, $username, $password) or trigger_error(mysql_error(),E_USER_ERROR); mysql_select_db($database); $size = count($_POST['newpicorder']); $i = 0; while ($i < $size) { $newpicorder = $_POST['newpicorder'][$i]; $id = $_POST['id'][$i]; $oldpicorder = $_POST['oldpicorder'][$i]; $query = "UPDATE propertiesimages SET picorder ='$newpicorder' WHERE propertyid = '$id' AND picorder='$oldpicorder'"; mysql_query($query) or die ("Error in query: $query"); print "$oldpicorder" . " updated to" . " $newpicorder". "<br />"; ++$i; } mysql_close(); ?> [attachment deleted by admin]
×
×
  • 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.