PHP - Why My Varchar(1000) Value Truncated In Php??
need your suggestion here is my problem i have field varchar(1000) in my sql server 2008 DB but if i mssql_fetch_object($result) my field value truncated and only show 256 character, why ?
in my DB . my field value really 1000 character long . Similar TutorialsI have some data that when I type in a string in a text box, (e.g. John Smith), the data is trunctated when it is inserted into the database (only 'John; would show up). I noticed that it seems to cut the data off after a white space. If I combine the words, then they are inserted properly. Does this sound like something simple I'm missing or is it something more complex? The text size is 20 and the db field is Varchar 30. Any help would be appreciated. Thanks. Hello PHP geniuses, I'm having a bit of trouble here. I've built a WYSIWYG e-mail editor with the help of TinyMCE. I'm using a textarea to pull the innerHTML from the iframe where the actual editor is. The textarea will be hidden in production, but it's shown now for debugging reasons. I have a JS function that grabs the HTML from the iframe and puts it into the textarea, and this works great. The entire HTML gets populated in the textarea. When I go to save the e-mail (using a simple query that posts it and sends it straight to the database). The HTML is truncated in the database field to around ~255 characters. (it varies depending on what I have in there, but it's usually between 252 and 255) I really can't figure out why this would be cutting off like this. I've looked everywhere, I don't know what else to do. I wanted to add that the field is a text field in the database, that was the first and most obvious thing to check. I can confirm that my database holds the full text no problem. I can go into phpMyAdmin and copy+paste infinite amounts of data into the html field and it saves it without an issue. Thank you as always <3 If you need more information to help me, I will provide whatever helps. Hi, the problem that I have goes like this. If i do a regular Select query and display it in a table everything is there but if i am filling a input box of a form to use for modifying the values it does not return the entire value: Exemple with the same value in a table = product_name : Amd Athlon X2 In input field : Amd Here is my code Code: [Select] <? $sql = "SELECT * FROM tbl_product WHERE product_code = '$_POST[productcode]'"; $result = mysql_query($sql); if(!$result){ die("Error running $sql:" . mysql_error()); } ?> <? while($row = mysql_fetch_array($result)) { echo " <form action='functions/moditem.php' method='post'> <input type='hidden' name='productid' value=". $row['product_id'] ."> Product code : <input type='text' name='productcode' value=". $row['product_code'] ." /><br /> Product Name : <input type='text' name='productname' value=". $row['product_name'] ." /><br /> Product Price: <input type='text' name='productprice' value=". $row['product_price'] ." /><br /> <input type='submit' value='Modify' /> </form> "; } Hi Guys, My 2nd issue with my new blog is that the code used to limit the amount of content displayed from each post, is on occasion truncating the closing html tags along with the excess text! Very often this will result in any following posts being entirely italic or bold, which as you can imagine looks ridiculous. The Code that limits the content: # Limit Post function the_content_limit($max_char, $more_link_text = '', $stripteaser = 0, $more_file = '') { $content = get_the_content($more_link_text, $stripteaser, $more_file); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $content = strip_tags($content, '<h1>,<h2>,<h3>,<strong>,<em>, '); if (strlen($_GET['p']) > 0) { I'd be very grateful if someone could help me out with this. Thanks Steve My DB has fields that primarily record numeric values. I've noticed that a NUMBER in a VARCHAR field is aligned to the right and will hold decimal places, and a SMALLINT seems to align left and strip whole numbers to the bare digit (eg.: 4.0 is held to 4). What's the best way for me to store values, if I want them to hold at least ONE decimal place (so that whole numbers line up EVENLY with fractions: 1.0 1.5 2.0 etc? Is there a way to "adjust" a setting within MySQL? Or in the query that pulls the info? Hello, I have a query that displays a list of events for the year, and am in need of guidance on how to have it only show events that are >= today's date. The 'date' is inserted into the table as a varchar field from javascript code. There was an old blog post about doing something like.... Code: [Select] SELECT * FROM calendar WHERE `date` >= NOW() ORDER BY date ASC LIMIT 5 I seem to have trouble in that i believe NOW() will only work with proper datetime entries as opposed to my varchar setup. any help navigating this would be great. I am not a developer and am learning so forgive lack of what may be obvious knowledge to you folks.
Our hosting provider has upgraded our version of SQL 5.7.7 which sets the default SQL mode to strict. As strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE we now have an error with some of our old PHP code. We are trying to insert a timestamp as follows
$insertSQL = sprintf("INSERT INTO tournaments (tourn_id, tourn_name, tourn_year, site_visible, tourn_type, ranking_type, tourn_class, how_seed, status) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", But we now get an error stating "Column tourn_year cannot be null"
The hosting provider has stated that since MySQL version 5.7.7 the default sql_mode is strict a value is missing when a new row to be inserted does not contain a value for a non-NULL column that has no explicit DEFAULT clause in its definition. As specified in https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict I am wondering what is the easiest least impactful way to fix this. Do I change to varchar (see image) or change the code? Thanks for your help in advance
how would i add text onto the end of a varchar field? i have tried using update like so: mysqli_query($link, "UPDATE ".TBL_PREFIX."posts SET post_likes = post_likes + ', $qu' WHERE post_id = '$post_id' ")or die(mysqli_error($link)); but that set the table to 0. Any ideas? I have a registration form and there is a part for Phone Numbers / Email it's option for either. My question is : The Field is a VARCHAR 255 , the max you can input on that registration field is 20 Characters? HOW Can i change the value to more like 30 - 40 characters ? please help. Jelly Bellys. So there are "recipes" of ones you can eat at the same time. The most well-known one is probably mixing a couple peanut butter jelly beans with a couple grapes. I have to say it's pretty good because they actually do taste like peanut butter and grapes, but I have one issue: the peanut butter flavor is too weak compared to the grape. Instead of a 1-1 ratio it takes more like 3-1. Weird thing, this has got to be the most famous recipe so why isn't it listed on their site? I see candy apple, tiramisu, and lemon meringue pie, but nothing about peanut butter and jelly sandwiches. Are they just not popular anymore? Personally I prefer peanut butter and chocolate (Nutella, specifically) but whatever. Which can't be that weird because Reese's is popular... Mind you peanut butter + Nutella sandwiches don't really taste like Reese's candies, but that could just be because of the type of chocolate. Like they use milk or dark chocolate while Nutella is based on hazelnut. Which reminds me, I have a jar of it in the cupboard, but it's been so long since I've used it that it might have turned into an oily mess by now. I know it's just the various oils and such separating but it looks like someone poured a teaspoon or two of water right into it and that just kinda puts me off the whole thing. Same for peanut butter for that matter except the "water" isn't clear. Dirty water. And mixing everything back together isn't so bad but it gets the knife dirty on the handle, which really bothers me because then my fingers get dirty and I have to stop what I'm doing and go wash my hands. I already do that enough each day, I don't want to make more reasons for me to do so. But beyond the oily mess there's also stuff getting stale. Stale Nutella is a pain because it's stiff and hard to deal with, and the kind of bread I like most is very soft and easily rips apart so spreading it on can be a real labor. Best method I've found is to spread a little bit on at a time but it takes so long to cover the whole face. Fine, it's a good sandwich, but in that same time I could have done something else. Maybe there's something in the freezer I could quickly heat up, or maybe there's some leftovers in the fridge I could eat. And if not there's pretty good odds that I need to go to the grocery store anyways. Ah, sorry. Forgot why I'm here. This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=358112.0 Hi, My site http://bittleships.com is a simple online battleships game. Theres a 1088 cell grid where each cell is a mysql database entry containing details wether its been clicked, if theres a boat in the location etc. the site usually loads all the querys in 0.3 seconds, but when 5 or more people are playing this easily hits 1+ seconds. The code that displays the grid is this: Code: [Select] echo("<center><span style='background-color:white;color:red;font-size:12'>$griderrormsg</span></center>"); } echo("<table width='20' border='0' cellspacing='0' cellpadding='0'"); for($i=1; $i<=32; $i=$i+1){ echo("<tr>"); for($j=1; $j<=34; $j=$j+1){ $c++; $cell = $c; $sql="SELECT * FROM grid WHERE `ID` = $cell"; $result=mysql_query($sql); $row = mysql_fetch_array( $result ); $clicked = $row['clicked']; if ($clicked == "1"){ echo("<td title='$j, $i'><img src='b.gif"); }elseif ($clicked == "2"){ //if the ship was hit $hitby = $row['user']; echo("<td title='$j, $i - Hit by $hitby.'><img src='h.gif"); }elseif ($clicked == "3"){ //if is chest $hitby = $row['user']; echo("<td title='$j, $i - $prevamount btc won by $hitby.'><img src='chest.gif"); }else{ echo("<td><a href='index.php?c=$c'><img src='g.gif"); } echo("' BORDER=0></td></a>"); } echo("</tr>"); } echo("</table>"); } Is there a better way of running this for it to run quicker? hi there..im new to php mysql and im having trouble inserting a string data to mysql from a php date() function. here's my code: Code: [Select] $year = date('Y'); echo $year; $insertSQL = sprintf("INSERT INTO tbl_elections (election_id=$year)"); mysql_select_db($database_organizazone_db, $organizazone_db); $Result1 = mysql_query($insertSQL, $organizazone_db) or die(mysql_error()); when i try to output the $year variable on a webpage, it returns "2012" but when i try to insert this data into my database table, it returns an error like this: check the manual that corresponds to your MySQL server version for the right syntax to use near '=2012)' is there a way to convert "2012" into a normal string data type? If I want to read in and process a CSV of a 1000 lines how easy is it to do without a database? By process, I mean read in the data and do simple manipulations + compare each line with a line from another file, that maybe have 50 lines I was just concerned that I might start hogging the CPU and memory of the server trying to process 1000 lines of data It's VERY important that I can do WITHOUT a database I'd only consider a database if it proves that not using will take too much CPU and memory I've only just began considering making the application - can't give full details - as I've got to figure them out myself! Any general advice would be great Thanks OM I have a varchar field called date that looks like this "2/06/2011 TUE" or like this "10/05/2011 WED". When I do an Order BY date Desc in php it does Not sort properly. Thanks for your assistance Steve |