![]() |
CRUD edit display issue
So here is my problem:
http://www.publisherbucks.com/crud.jpg The code I'm using for that form is as follows: Quote:
http://www.publisherbucks.com/crud2.jpg I'm assuming it has something to do with the database row, although I'm not sure why the first area for 'title' isn't displaying the full entry as there is no HTML markup in that column? Any pointers or help from those of you 'in the know' please? This is actually the first time I'm trying to use CRUD on this system, I have a similar system setup for a domain management setup but that just uses 2/3 words in each column and it works fine (I copied across the edit.php exactly and just changed out the column names on this). At this point I'm honestly at a loss as to why it isnt working, I've also tried using the <textarea> instead of text input to display the data and that didn't work either :Oh crap |
You didn't wrap the value parameter of your inputs in quotes.
|
Quote:
|
PHP Code:
|
You can't put HTML tags inside an input field. So those <BR> tags need to be converted to "\r\n".
You could do for example, $Ingredients = str_replace("<BR>", "\r\n", $Ingredients); Then the line to display it should use <textarea> <td><textarea name="Ingredients"><?php echo $Ingredients;?></textarea></td> |
Awesome, thank you both for your help with this, I have it running correctly now :thumbsup
|
I'm having another really strange issue with this edit.php on the crud system, does anyone know what might be causing it not to add data to the Category field?
Everything else appears to be working correctly, but it isnt allowing me to add new data (when editing) to this field specifically. Its set as mediumtext in the database and only have 2 words seperated by a comma presently so the space in the column shouldn't be an issue. The code is exactly as above so should be working fine. Adding a new record isnt giving me any issues and neither is displaying or deleting a record :Oh crap Any thoughts on what may be causing this issue please? |
Quote:
|
Quote:
I'm wondering if its an issue with the connection although, no errors appear to be showing in the logs other than a modify header one to redirect to the main index.php page, which ill deal with later. Quote:
|
Did you try using my code? It fixes that headers already sent, and isn't full of sql injection exploits in literally every possible place one could be :)
Does the data you are putting into categories contain a ' ? because that would be enough to cause an SQL error in your code. |
Quote:
|
Quote:
Can't see anything wrong at first glance but when trying to debug this sort of thing you should try to find out exactly what is going wrong. To do this I would change $result = mysqli_query($mysqli, "UPDATE Recipe SET Title='$Title',Ingredients='$Ingredients',Method=' $Method',Category='$Category',Edit='$Edit' WHERE RecipeID=$RecipeID"); to $query = "UPDATE Recipe SET Title='$Title',Ingredients='$Ingredients',Method=' $Method',Category='$Category',Edit='$Edit' WHERE RecipeID=$RecipeID"; $result = mysqli_query($mysqli, $query) or die(mysqli_error($mysqli) . " query was $query"); This will spit out an error if the insert failed and stop the script right there, telling you what the actual query was you were trying to use. Obviously remove this code for the live version, and set up a proper try...catch construct, this is just a quick way to see what's going on. If that doesn't give any error message the problem is somewhere else. |
Quote:
Quote:
Found it, there an an unescaped single quotation mark at the end of confectioners' sugar. Thanks again for the help guys, looks like ill be running a quick search & replace on the database to make sure that issue doesnt happen again :) |
You just need to do
$Ingredients = addslashes($Ingredients); before trying to construct the query string with it. Do it with all the other vars too. Or to be more thorough you should use mysql_real_escape_string() as Konrad suggested. |
Quote:
. |
i just updated this to the code suggested by Konrad :)
Again, thank you all for your assistance with this :thumbsup |
Quote:
|
All times are GMT -7. The time now is 01:15 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc