It has been three days trying to solve my form to submit correctly. I ended up installing codeigniter and grocery crud again but it's always the same problem.
If I type a url inside the input to update it in the database It will not work:
http://example.cc
but if I add a return (empty line) before it it submits correctly.,
(NEW LINE)
http://example.cc
Meanwhile, I'm unable to update a column with html if it contains certain tags such as
<input>
just click on project properties and try to update the youtube video url or try to change the paypal_form
Edit: and what I find really strange is that I can update the description column of the table that came with the example (click on products link and try to put the code below and it works ) but not for project properties -> desription
Here's an example line of code that if I type the form doesnt submit :
<input>
below is the database i'm trying to edit through grocery crud
So what can cause this problem ? my table and the table of the example have the same column types except the number of columns and their names that is different
and below is the code I'm using in my controller to produce the table:
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('uf_object_properties');
$crud->set_subject('Property');
$crud->required_fields('value');
$crud->columns('property_name', 'property_value');
$output = $crud->render();
$this->load->view('myview.php', $output);
Grocery_CRUD will strip any tags from the input from a text input to make the content safe. If you want to add HTML change the datatype of your mysql column to "text" and use the HTML editor. There is probably a work around but you would need to get into the library code.
Ok after struggling a lot with it, it turned out to be a BUG in the grocery crud.
Simply, if the column name contain the letter V or something like that it wont work properly with html tags or special charachters
I started deleting column by column from the example that worked for me to make the table structure I want, after reducing all columns it was working, after that i started to rename them column by colum and once i renamed the column 'productDescription' to 'propertyValue' which is the name I wanted for the column it stopped working. So I started deleting letter by letter and found out the problem was with the column name.
Exmple of column names that produce this problem :
propertyValue
propertyVal
propertyV
propertyValeur
so I just replaced the second word value with the another word and problem was solved.
But seriously this is a very confusing bug that needs to be fixed sooner or later
EDIT :
The names above doesn't cause grocery crud to stop working at all, it just make it unable to submit such information which contain for example <input> or a link such as http://exmple.cc
Thanks all for the help
Related
I would like to conditionally display table row in predefined Ms Office Word file. The solution I am using currently only allows to manage display of whole block and so on the whole tables according to different combination of displayed data. I find this solution obscure. This is why I need conditionally display table row.
Current solution works with:
$$nameofdesiredkey
the conditionally shown content
nameofdesiredkay$$
I was able to solve that issue by workaround using another data table as result of dynamic values from pontential spread of values in the original table.
During my reserach idea of using multiple tables, using one dynamic data table list in one TD or just using $$variablestart variableend$$ and the start and end of each of nearest surrounding TDs seemed potent also.
The table (images_list is the name of the table) I have to update has over 500 rows with a certain link which I have to replace to a url connected to a local folder.
For example a field will contain www.google.com/img/test-more-text.gif and this has to be replaced to /image/test-more-text.gif. The prefix link is exactly the same for each row, the only variable part is the image name (test-more-text.gif for example is the only variable part in the example given above)
I've looked up multiple tutorials but the only things I can find replace the complete field whereas I need to keep the suffix so to speak.
This image obviously has a different name aswell so I can't simply do
UPDATE images_list
SET image_link = '/image/test-more-text.gif'
WHERE image_link = 'www.google.com/img/test-more-text.gif'
I know how to lookup text with the LIKE statement but I've never had to update something like this before.
If anyone knows how to do this that would safe me a ton of work
Use the REPLACE function:
UPDATE images_list
SET image_link = REPLACE(image_link, 'www.google.com/img/', '/image/');
WHERE image_link LIKE 'www.google.com/img/%'
I have a mysql table that looks like this:
id author public image1 image2 image3 bio media1 media2 media3 media4 media5 media6
The Field "author" normaly has Firstname (Secondname) Lastname seperated by whitespaces.
How can I sort the array after the Lastname and if just one name is present after this one.
This is the modx query I use to sort after the author but obviously it doesn't use the lastname.
$c = $modx->newQuery('AuthorDe');
$c->sortby('author','ASC');
$authors = $modx->getCollection('AuthorDe',$c);
You're shooting yourself in the foot right now, for a couple of reasons:
When there is only one word in the string, the sorting is hard to predict.
You have indexes for your data for a reason. They make it a lot faster. Using string functions force a table scan. Good enough for 100 data units, slow for 10000 rows and 'database went for a vacation" at 1000000.
Next time you have to use the author field and you realize you have to split it up to words you also have to understand and fix this code snippet on top of the old ones.
That said - I haven't tested it - but try this:
$c->sortby('substring_index(author," ",-1)','ASC');
So to elaborate on the very valuable point jous made, putting multiple points of data in one database column is counter productive.
The sorting you want to do would be simple, fast, & efficient, in a sql query (using the same construct jous showed but without the string operation).
To modify this table you would simply add the following columns to your table in place of author:
firstname
lastname
middlename
To show you how simple this is (and make it even easier) here's the code to do it:
ALTER TABLE [tablename]
ADD COLUMN firstname varchar(32)
ADD COLUMN lastname varchar(32)
ADD COLUMN middlename varchar(32)
DROP COLUMN author;
Then the modx PHP code would be:
$c->sortby('lastname','ASC');
So this is fairly easily done... and if you still need to support other references to author then create a view that returns author in the same way the un-altered table did as shown below (NOTE: you would still have to change the table name reference so it points to the view instead of the table... if this will be a big problem then rename the table and name the view the same as the old table was...):
CREATE VIEW oldtablename AS
SELECT firstname+' '+middlename+' '+lastname' ' AS author
FROM newtablename;
NOTE: if you do create a view like the above then it is probably worth your while to add all of the other columns from the new table (the multiple image & media columns).
NOTE2: I will add, however, that those would ideally be in separate tables with a join table to this one... but if I were in your spot I might agree that expedience might beat utility & future usability.... however if you did put them in different tables you could add those tables to this view (as joins to the new table) and still be able to support existing code that depends on the old table & it's structure.
While the above is all fairly easily done and will work with minor adjustments from you the last part of this is getting your custom table changes to be reflected by xPDO. If you are already comfortable with this and know what to do then great.
If you aren't this is by far the best article on the topic: http://bobsguides.com/custom-db-tables.html
(Yes it is worth getting Bob's code as a snippet so all of this can simply be generated for you once the database changes have been made... (remember you will likely need to delete the existing schema file & xpdo related class files & map files before you run Bob's generation code, or your changes that have the same table name, like the view, won't take effect).
Hope this helps you (or the next person to ask a similar question).
I am exporting data into a pdf using TCPDF. Everything works fine until I add a certain column (long text format) to the table. Whenever I add it, the table doesn't show up. When I run the sql query all the data shows up fine.
Is it possible there's a character or characters in the data field itself that are causing the table to become corrupted?
Also I can't for the life of me, figure out how I show more than 256 characters in cell.
If anyone can help I'd really appreciate it.
well until I find a better option I am running this to each of my comment fields
UPDATE TABLE_NAME set COLUMN_NAME = replace(COLUMN_NAME, '’', '`');
I have a tab delimited text file with the first row being label headings that are also tab delimited, for example:
Name ID Money
Tom 239482 $2093984
Barry 293984 $92938
The only problem is that there are 30 some columns instead of 3 so I'd rather not have to type out all the (name VARCHAR(50),...) if it's avoidable.
How would I go about writing a function that creates the table from scratch in php from the text file, and say the function takes in $file_path and $table_name? Do I have to write all the column names again telling mysql what type they are and chop off the top or is there a more elegant solution when the names are already there?
You would somehow need to map the column type to the columns in your file. You could do this by adding that data to your textfile. For instance
Name|varchar(32) ID|int(8) Money|int(10)
Tom 239482 $2093984
Barry 293984 $92938
or something similar. Then write a function thet get's the column name and columntype using the first line and the data to fill the table with using all the other rows. You might also want to add a way to name the given table etc. However, this would probably be as much work (if not more) than creating SQL queries using you text file. Add a create table statement at the top and insert statements for each line. With search and replace this could be done very fast.
Even if you could find a way to do this, how would you determine the column type? I guess there would be some way to determine the type of the columns through checking for certain attributes (int, string, etc). And then you'd need to handle weird columns like Money, which might be seen as a string because of the dollar sign, but should almost certainly be stored as an integer.
Unless you plan on using this function quite a bit, I wouldn't bother spending time cobbling it together. Just fat finger the table creation. (Ctrl-C, Ctrl-V is your friend)