PHP - Character Issue With Sql
Similar TutorialsI know via firebug that the correct parameters were passed to my process page and the parameter being passed that in caused issues on the process page is $characterIDList. What's causing the issue is that its not inserting the value into the insert query. The rest of the insert query works fine. process page $characterIDs = explode(',', $_POST['characterIDList']); foreach($characterIDs as $itm){ $id = (int)$itm; } $defaultcharid = (int)$characterIDs[0]; $query = "INSERT INTO `handlers` (username, password, firstname, lastname, email, status_id, isadmin, default_character_id, creator_id, datecreated) VALUES ('$username','$password','$firstname','$lastname','$email','$status','$admin', '$defaultcharid', 1, NOW())"; Can someone help me with this. I think I need to use substr: how do I only echo out everything after the period ( ".") for example if I have "table.birthday" I want to echo: "birthday" all i want is for when their is a _ to be replaced with a space so i tried these and neither worked Code: [Select] <?php $pmod = str_replace("_"," ",$p); $pmod = preg_replace("_"," ",$p); ?> so i was wondering if because this was in a while statement, is this the reason its not working, and if so how should i fix it (this is the while) Code: [Select] <?php while ($z <= $w){ $p = $multi[$z]; $pmod = str_replace("_"," ",$p); echo "<a href='tag.php?tag=$p'" . $p . ">" . $pmod . "</a> "; $z++; } ?> Hey, I'm having an issue with using Wikipedia's OpenSearch API - it sometimes gives me characters in a unicode format: "\u00f1" and I would like to convert back into a correctly displayed format (in this case, n-tilde; spanish n). Any suggestions? HI all, something that keeps bothering me is that i do not fully understand the usefullness of the \n newline character. When i use for testing in a string it doesn't show the effect in my browser. Only when I press view source I can see that right after the \n character the code jumps down 1 line. Does anyone know how and when to use it? I have see it with the php mail function, but i don't really understand why they use it. If someone could enlighten me i would be very happy Thanks to the advice of others on PHPFreaks, I have decided that allowing any character for certain fields on my "Add an Article" form. However, I still want to define a length between 2 and 100. How do I re-write my RegEx to accomplish this? Befo Code: [Select] // Check HTML Title. if (empty($trimmed['htmlTitle'])){ $errors['htmlTitle'] = 'Please enter an HTML Title.'; }else{ if (preg_match('#^[A-Z \'.-]{2,100}$#i', $trimmed['htmlTitle'])){ $htmlTitle = $trimmed['htmlTitle']; }else{ $errors['htmlTitle'] = 'HTML Title must be 2-100 characters (A-Z \' . -)'; } } Here is my best guess... After: Code: [Select] // Check HTML Title. if (empty($trimmed['htmlTitle'])){ $errors['htmlTitle'] = 'Please enter an HTML Title.'; }else{ if (preg_match('#^[.*]{2,100}$#i', $trimmed['htmlTitle'])){ $htmlTitle = $trimmed['htmlTitle']; }else{ $errors['htmlTitle'] = 'HTML Title must be 2-100 characters (A-Z \' . -)'; } } Debbie I have problem, there are users with "?" character in username, and their address to profile is /profile/username/. I have var: $username that is that username, now, how can i replace all that characters which cant open users profile.. I mean for "?" i need to put "%3F", how can i replace? I know with str_replace, but is there any other solution like htmlencode or something like that? :S so if I have a a string of text or something like Code: [Select] http://www.yahoo.com/ajhsijd908340 I can use str_replace to remove "http://" but what can I use to remove the "ajhsijd908340" if every time it is a different set of characters? Hi, does anybody know why I get a question mark inside a diamond shape where a pound sign should be when i retrieve data from a mysql database? I have tried using latin1_general_ci and utf8_general_ci and they both do the same, don't know whether that is anything to do with it or not? Any help would be greatly appreciated. I got another problem. It is a counting characters. When I reload text from database, I want to count how many characters are in text. The problem is that I use the timymce, and there is a tags </p> and formats <span> and other formats. How can I count characters without those format, just pure characters entire text? I need a php code. And some plus - text is in utf8 coding in database with utf8 bin. All, I have a zip code and for example the zip code is 01101. How can I determine if the first character in this is a zero? Thanks in advance. If I was pulling back data from MySQL that was like this "monkeys / dogs / cats", how would I grab just "monkeys" from that using PHP? In other words, I want to grab all text until a "/" is seen. How to remove the last character of a string if it is "-" ? In replacing some elements in strings, sometimes "-" remains at the end. How to trim the string by removing "-", if it is at the end of the string? Hello, I am trying to find a character in my DB's. The DB has the data setup with +(number) & -(number) I want to try and find a way for PHP to seperate them into two so each one has the seperate colour's. i have tried preg_match, strstr & strpos but none of them seem to work. Can you as PHP Genius's help out? EDIT: Please Do Not Worry, I have fixed this. For people who were wondering: $new_variable = strstr($variable_to_check, "+"); if($new_variable == "") { do one you want } else { do what you want. } Thanks PHP Freaks Thanks, NoMansLand I am trying to find a character in the follwing string $string = ' Mumbai Mast Kallander - 02 - Mumbai Mast Kallander'; the character i want to find is '-' and the find how many times does it occur in the string.. can anyone help? hello; I have: mysql: utf8_general_ci index.php: header( ... UTF-8) index.php: <meta ... content-type ... UTF-8> index.php, mysql query procedu ... mysql_set_charset( utf8 , .. ) ... So, if I put a special character in my db, it WILL display correctly in index.php But, if I put the same character in a php variable, it is BAD ... diamond-shape with question mark inside Since my special characters work from the db, I would like to also use them in html (index.php ). am I missing anything? thanks for your time .. Shannon I'm having a problem that I didn't seem to have in the past... for some reason, it just popped up... or maybe I'm just noticing it. Anyway, I this in a field in a mysql database: "Here's a test." When I query the database and echo the text to the page with this code: Code: [Select] $result = mysql_query("SELECT question FROM signin WHERE email = '$email'") or die (mysql_error()); $row = mysql_fetch_row($result); $test = $row[0]; echo $test; This is the result: "Heres a test." Any ideas on why the apostrophe is not being displayed and how to fix it? I'm stumped. Thanks for any help. |