Jump to content

SamCec

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

About SamCec

  • Birthday 11/18/1943

Profile Information

  • Gender
    Male
  • Location
    SouthEast PA

SamCec's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. KickStart and PFMaBiSmAd: Sorry for the delay in getting back to you, I had to go out. Thank you so much for the corrected code and the explanation. Your code did the trick. I now have the items in alphabetic order. Thanks Again, Sam
  2. It's going to take me some time to figure how to do what your asking. I am aware that "objectname" is populated. There is a record for each object. The objects are: Bunny, Butterfly, Cardinal, etc. You can see all of the objects by going to: www.woodartbysam.com/test If you go there, please keep in mind there is still a lot of work to be done on the site. Sam
  3. Folks: let me re-explain: Someone else wrote this for me because I DON'T KNOW php. Here are the 1st 28 lines of the app. PLEASE SEE MY COMMENTS AFTER THIS CODE. <?php include('connect/connect.php'); mysql_select_db($database) or die ("Unable to Connect to the database"); $woods = array(); $selectWood = "SELECT * FROM `wood`"; $queryWood = mysql_query($selectWood) or die(mysql_error()); while($item = mysql_fetch_array($queryWood)) { $woods[$item['index']] = array($item['name'], $item['photo']); } $objects = array(); $selectObjects = "SELECT * FROM `objecten` ORDER BY ".$item['objectName']." "; $queryObjects = mysql_query($selectObjects) or die(mysql_error()." $selectObjects"); while($item = mysql_fetch_array($queryObjects)) { array_push($objects, array( $item['objectName'], split(";", $item['photos']), $item['price'], $item['base'], $item['centerPiece'], $item['name'], $item['wood'])); } without the ORDER BY clause the code works fine. I know a little SQL so I originally added the "order by". When it didn't work, that's when I came for help. Sam
  4. KickStart: Here is the error I received after changing the "die" clause: 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 '' at line 1 SELECT * FROM `objecten` ORDER BY
  5. chintansshah: Your code gave me the following 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 '' at line 1" Sam
  6. Thanks for the suggestion but I pasted the code you supplied in my application and got this 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 '' at line 1" Sam
  7. Hi: I'm new to PHP and Mysql. Wondering if you can help? This code works without the "order by" clause but with it, I get a parsing error. I do want the records sorted by "objectname", I also tried "ordered by $item['objectName']". That didn't work either. I got the same error. $selectObjects = "SELECT * FROM `objecten` [color=red]ORDER BY $item['objectName']";[/color] $queryObjects = mysql_query($selectObjects) or die(mysql_error()); while($item = mysql_fetch_array($queryObjects)) { array_push($objects, array( $item['objectName'], split(";", $item['photos']), $item['price'], $item['base'], $item['centerPiece'], $item['name'], $item['wood'])); }
  8. On an HTML Form, I have several Text boxes called "base1, base2...base13" Another text box I have is called "base_quantity" In my PHP routine: This is part of my code: $selected_base = $_POST['base1']; if ($selected_base == 'yes') { $base_value = $base_value + 1; $base_status = 'Yes'; } else if ($selected_base == 'no') { $base_value = $base_value - 1; $base_status = 'No'; } Later on in the PHP routine I want to pass back to the Form the value of $base_status and place it in the "base_quantity" text box. Something like this: base_quantity = $base_value. Can someone tell me how information is passed back to the FORM. Thank You, Sam
  9. By always do you mean you get it EVERYTIME no matter what, even if the field is blank. because according to your code...error is only set to one when the username passes the test...of validation also...it might help on your preg_match if you took away the dollar sign...there's really no need for it. I'm sure if you change you code to this though, your problem will be solved if(!check_field1($Fname)) { $error = 1; zanus: I appreciate the response I did change the "IF" statement, ran the procedure and I am getting the "Name is Required" message no matter if I put a name in or leave it blank. I am attaching a "zip" file that contains the GuestBook.html and the php. If you try this on your machine, don't forget to change the "To$" in the php routine to your email address. Thanks, Sam [attachment deleted by admin]
  10. Hi Folks, I'm new to PHP. I have a problem that I have been trying to figure out. Right now, I am totally lost. Here's my code; afterward I will explain the problem. <html> <body> <?php $error = 1; function check_field1($newVariableName) { if(preg_match("/[^a-zA-Z0-9\.\-\Ä\ä\Ö\ö\Ü\ü\ ]+$/s",$newVariableName)) return TRUE; else echo 'Name is REQUIRED!'; return FALSE; } if ($_POST) { $Fname = $_POST["username"]; $Fmail = $_POST["usermail"]; $FAddress1 = $_POST["Address1"]; $FAddress2 = $_POST["Address2"]; $FCity = $_POST["City"]; $FState = $_POST["State"]; $FZip = $_POST["Zip"]; $FPhone = $_POST["Phone"]; $FSite = $_POST["site"]; $FComment = $_POST["comment"]; $to = "myemail@example.com"; $subject = "Guest Book Entry"; $from = "someonelse@example.com"; $headers = "From: $from"; $message ="\r\n Username: " . $Fname . "\r\n Usermail: " . $Fmail . "\r\n Address1: " . $FAddress1 . "\r\n Address2: " . $FAddress2 . "\r\n City: " . $FCity . "\r\n State: " . $FState . "\r\n Zip: " . $FZip . "\r\n Phone: " . $FPhone . "\r\n Site: " . $FSite . "\r\n Comments: " . $FComment; if(check_field1($Fname)) { $error = 1; } if($error == 0) { // If there are no errors then if (mail($to,$subject,$message,$headers)) { echo '<p>The Guest Book was updated. Thank You.</p>'; echo '<center>'; echo '<a href="Index.shtml">HOME</a>'; echo '</center>'; } } } ?> </body> </html> This routine is being called by an Action tag on a <form>. The USERNAME field is required. The validation is not working. I'm always getting the same result ($error = 1). I did not code the parameters on the "preg_match", someone else coded that for me. All I really want to do is test for alpha characters(upper and lower case). A thought I had--maybe I should, on the form, break down USERNAME into FirstName and Lastname. Reason: the space in between FirstName and LastName in the Username field might be causing me a problem. What do you think? Can you help?
  11. I still need help Here's what I have on the code: <html> <body> <?php function check_field1($fname) { if(!preg_match("/[a-zA-Z]+$/s",$Fname)) return TRUE; else echo 'Name is REQUIRED!'; return FALSE; } if ($_POST) { $Fname = $_POST["username"]; $Fmail = $_POST["usermail"]; $FAddress1 = $_POST["Address1"]; $FAddress2 = $_POST["Address2"]; $FCity = $_POST["City"]; $FState = $_POST["State"]; $FZip = $_POST["Zip"]; $FPhone = $_POST["Phone"]; $FSite = $_POST["site"]; $FComment = $_POST["comment"]; $to = "myemail@example.com"; $subject = "Guest Book Entry"; $from = "someonelse@example.com"; $headers = "From: $from"; $message ="\r\n Username: " . $Fname . "\r\n Usermail: " . $Fmail . "\r\n Address1: " . $FAddress1 . "\r\n Address2: " . $FAddress2 . "\r\n City: " . $FCity . "\r\n State: " . $FState . "\r\n Zip: " . $FZip . "\r\n Phone: " . $FPhone . "\r\n Site: " . $FSite . "\r\n Comments: " . $FComment; if(!check_field1($Fname)) { $error; } if($error == 0) { // If there are no errors then if (mail($to,$subject,$message,$headers)) { echo '<p>The Guest Book was updated. Thank You.</p>'; echo '<center>'; echo '<a href="Index.shtml">HOME</a>'; echo '</center>'; } } } ?> </body> </html> The function is not working. First of all, the USERNAME can be entered as FirstNameSpaceLastName. My intent: if the username is not entered, show the words "Name is Required" and DO NOT send the e-mail. If the USERNAME is entered, then send the e-mail. What is currently happening, the e-mail is sent even when nothing is in the USERNAME. I was thinking about using the strlen function and checking for a length > 0. I tried that and my syntax was wrong. Question: Is there a better way to do this? Should I have separate <INPUT> tags for FirstName and LastName?
  12. Like i indicated ^^ But nice addon to my solution Folks: Thank you so much for your help. I am not getting any "Parsing" errors, The function is not working. I believe it is checking spaces as a valid character and therefore returning a TRUE even when I do not enter a name. The USERNAME can be entered FirstNamespaceLastname. Question: In PHP can you check the length of the input? Thanks again, Sam
  13. indeed thats the problem open wordpad delete that " replace it with a new " from wordpad wich will make it work Folks: I don't think I was meant to be a PHP coder. Your above solution worked but... I checked the spelling and it looks good.
  14. Thank you, that helped but now I am getting a Parse error on line 47, the </body> tag. I then removed the <body> and </body> tags and the Parse error still appeared on the preceding lines.
  15. Before 2 days ago, I knew nothing about PHP. I read some tutorials and followed some examples and got to this point. I don't do this for a living, I'm retired and trying to keep the mind active. I wrote using HTML a page that has a <form> tag on it. The <form> tag has ACTION = "mail.php". The contents of the form, I want e-mailed to me. Without the attempted "IF" clause THAT PART IS WORKING. The first input of the form is username--that's required. I am having trouble with that. Here is my code of "mail.php": <html> <body> <?php if ($_POST) { $Fname = $_POST["username"]; $Fmail = $_POST["usermail"]; $FAddress1 = $_POST["Address1"]; $FAddress2 = $_POST["Address2"]; $FCity = $_POST["City"]; $FState = $_POST["State"]; $FZip = $_POST["Zip"]; $FPhone = $_POST["Phone"]; $FSite = $_POST["site"]; $FComment = $_POST["comment"]; $to = "myemail@example.com"; $subject = "Guest Book Entry"; $from = "someonelse@example.com"; $headers = "From: $from"; $message ="\r\n Username: " . $Fname . "\r\n Usermail: " . $Fmail . "\r\n Address1: " . $FAddress1 . "\r\n Address2: " . $FAddress2 . "\r\n City: " . $FCity . "\r\n State: " . $FState . "\r\n Zip: " . $FZip . "\r\n Phone: " . $FPhone . "\r\n Site: " . $FSite . "\r\n Comments: " . $FComment; if(!check_field1($Fname)) { $error; } if($error == 0) { // If there are no errors then if (mail($to,$subject,$message,$headers)) { echo '<p>The Guest Book was updated. Thank You.</p>'; <center> <a href="Index.shtml">HOME</a> </center> } } function check_field1($fname) { if(!preg_match("/[^a-zA-Z0-9\.\-\Ä\ä\Ö\ö\Ü\ü\ ]+$/s”,$fname)) return TRUE; else echo 'Name is REQUIRED!'; return FALSE; } } ?> </body> </html> When I run this, I get this error: which is the <center> tag. I then took the <center> and </center> tags off but left the line positioning the same. I got this error: This is the <a...> tag. Sorry folks, I can't figure what the problem is. I need help. Thanks, Sam
×
×
  • 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.