Jump to content

Luodeni

Members
  • Posts

    10
  • Joined

  • Last visited

    Never

Everything posted by Luodeni

  1. hey everyone. I just started out using FCKeditor for PHP and it works relly nice. Just I wonder how to get my data back from a dubmit like i'd normally do with text field or whatever. but once i write <?php $oFCKeditor->Value = echo $_POST['otherjobinfo']; ?> it returns to me with a parse error. Does anyone know why? any help would be really appreciated
  2. I made a function to check whether the first/middle/and lastname already exists in my database. It works just fine for latin names but it does not work on Chinese for example. My database has the value stored as unicode aswell and the characters represent the same I used (星星张 (xingxing Zhang)) as a name to check. Strangely enough it says this one doesn't exist yet, although it does. did anyone ever encountered this problem? here is the function <?php function checkDuplicateContact( $firstName, $middleName, $lastName ) { $SQL = "SELECT customerid, firstname, middlename, lastname FROM tb_contacts WHERE firstname = '$firstName' AND middlename = '$middleName' AND lastname = '$lastName' "; $res = mysql_query( $SQL ); if ( mysql_num_rows( $res ) == 1) { $error = "<div style='color: #D00;'>" . $_POST['firstname'] . " " . $_POST['middlename'] . " " . $_POST['lastname'] . ", already exists!</div>"; } elseif ( mysql_num_rows( $res ) == 0 ) { require 'includes/dbConnect.php'; mysql_query("SET CHARACTER SET 'utf8'"); mysql_query("SET NAMES 'utf8'"); $SQLAdd = "INSERT INTO tb_contacts ( firstname, middlename, lastname, age, gender, dateofbirth, married, children, nationality, religion, companyid, jobtitle, jobdescription, officephone, homephone, mobilephone, mobilephone2, email, email2, instantmessenger, instantmessenger2, fax, hobbies, favouritefood, favouritebeverage, miscelleneous, createdby, createddate ) VALUES ( '$firstName', '$middleName', '$lastName', '$age', '$gender', '$dateofBirthFull', '$martialState', '$children', '$nationality', '$religion', '$companyId', '$jobTitle', '$otherJobInfo', '$officePhone', '$housePhone', '$mobilePhone', '$mobilePhone2', '$email', '$email2', '$instantMessenger', '$instantMessenger2', '$fax', '$hobbies', '$favouriteFood', '$favouriteBeverage', '$miscelleneous', '$createdBy', CURRENT_TIMESTAMP() ) "; $resAdd = mysql_query( $SQLAdd ); mysql_close(); $error = "<div style='color: #48830b'>" . $_POST['firstname'] . " " . $_POST['middlename'] . " " . $_POST['lastname'] . ", added to the database</div>"; $_POST = ""; } else { $error = "<div style='color: #D00;'>" . mysql_error() . "Please contact the webadmin</div>"; } return $error; } ?> <?php if ( isset( $_POST['firstname'] ) && $message != "") { echo "<div style='color: #D00;'>" . $message . "</div><br />\n"; } elseif ( isset( $_POST['firstname'] ) && empty( $message) ) { echo checkDuplicateContact( $firstName, $middleName, $lastName ); } ?>
  3. Most likely you are missing a ";" or a "}" the easiest way to find this out is to to use IDE that has color highlighting when u click on a curly brace. Maybe you could upload the code here and we could have a look.
  4. I created a function to dynamically create a list of date available which will later be checked with checkdate(). Now the funny thing is that i was able to echo the result back from the user but it just created a new <option> which isn't very neat. Therefore I'd like to ask whether anyone knows how to do this neatly, that means selecting the value from the already generated list. many thanks in advance here is the code <?php function createMonths() { for ( $iMonth = 1; $iMonth <= 12; $iMonth++ ) { echo "<option>" . $iMonth . "</option>"; } return $iMonth; } function validDateCheck( $dobMonth, $dobDay, $dobYear ) { if (checkdate( $dobMonth, $dobDay, $dobYear) == true ) { $message .= ""; } else { $message .= $dobMonth . "-" . $dobDay . "-" . $dobYear . " Is not a valid date, please correct it! <br />"; } return $message; } ?> <select name="dateofbirthmonth" tabindex="7" class="dropdownStyle" style="width: 37px; "> <?php if ( $_POST['dateofbirthmonth'] != "") { echo "<option value=" . $_POST['dateofbirthmonth'] . " selected>" . $_POST['dateofbirthmonth'] . "</option>"; } else { echo "<option value='00' selected>M</option>"; } ?> <?php createMonths(); ?> </select>
  5. if(mysql_num_rows($result)>0) since it's for a user try this: if ( mysql_num_rows ($result) == 1 ) OR if ( mysql_num_rows ($result) != 0 )
  6. yes I was actually aware of that but as you already said it's only for birthdays and I don't know anyone who's 109 years old and still working hahah thanks to PFMaBiSmAd for the PHP checkdate() function. I ammended the codeto this now. which is much neater <?php function validDateCheck( $dobMonth, $dobDay, $dobYear ) { if (checkdate( $dobMonth, $dobDay, $dobYear) == true ) { $message .= ""; } else { $message .= $dobMonth . "-" . $dobDay . "-" . $dobYear . " Is not a valid date, please correct it!"; } return $message; } ?>
  7. I created afunction which works with 3 dropdown menu's to get the date but no matter whether a date is a leapyear or not it always says it's an invalid date here's the code <?php function validDateCheck( $dobMonth, $dobDay, $dobYear ) { $message = ""; if ( $dobMonth == 2 || $dobMonth == 4 || $dobMonth == 6 || $dobMonth == 9 || $dobMonth == 11) { if ( $dobDay > 30) { $message .= $dobMonth . "-" . $dobDay . "-" . $dobYear . " is not a valid date. Please check and correct it! <br />"; } elseif ( $dobMonth == 2 && $dobDay > 28 ) { if ( ($dobMonth == 2) && ($dobDay == 29) && ($dobYear % 4 != 0) ) { $message .= $dobMonth . "-" . $dobDay . "-" . $dobYear . " is not a valid date. Please check and correct it! <br />"; } elseif ( ($dobMonth == 2) && ($dobDay >= 29) ) { $message .= $dobMonth . "-" . $dobDay . "-" . $dobYear . " is not a valid date. Please check and correct it! <br />"; } } } return $message; } ?>
  8. ah such a small little mistake but it's working now. thanks.
  9. hey everyone, I ve kind of a newby question. I first had this piece of code <?php if ( empty( $_POST['firstname'] ) { $message .= "error"; } if ($message != "") { echo "<div style='color: #D00;'>" . $message . "</div><br />\n"; } elseif ( empty( $message) ) { echo "correct <br />"; } ?> then I changed it to <?php function isNullOrEmpty( $valueToCheck ) { if ( empty( $valueToCheck ) ) { $message .= "You have to fill the contact's " . $valueToCheck . "! <br />"; } else { $message = ""; } return $message; } isNullOrEmpty( $_POST['firstname'] ); if ($message != "") { echo "<div style='color: #D00;'>" . $message . "</div><br />\n"; } elseif ( empty( $message) ) { echo "correct <br />"; } ?> but now it always says my code is correct even when the field is empty. Does anyone knows what I am doing wrong with my function? many thanks in advance
  10. hey everyone, Earlier today I was doing some PHP programmign for a web application I m making and I got a very unpleasent error. My application is UTF-8 and that works fine. But when I was updating a record which uses chinese characters for example it just made a weird character. thsi was caused because I used <?php $companyStreetName = mysql_real_escape_string( ucfirst( $_POST['companystreetname'] ) ); ?> Now I found out the error was caused by the ucfirst() so I rewrote my code to this: <?php $companyName = mysql_real_escape_string( $_POST['companyname'] ); if ( ereg('[a-z]', $companyName) ) { $comapnyName = ucfirst( $companyName ); } else { $companyName; } ?> however It doesn't work for some reason, does anyone know why not? i d be very happy if someone could help me with this
×
×
  • 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.