Showing error: Unknown HTML tag - phpstorm

So i just started using Phpstorm and I am trying to 'correct' my code so there are no errors from the IDE. I have the following method below and all my xml tags are highlighted with the 'Unknown HTML tag'
What is the best way to correct this?
private function generate_qbxml_CustomerAddRq($requestID=0){
/** requestID is used when multiple requests are called in order to match the request to the response.
requestID's should be incremented as they are called. Currently not implimented. **/
$qbxml = '';
$qbxml .= '<?xml version="1.0" encoding="utf-8"?>';
$qbxml .= '<?qbxml version="2.0"?>';
$qbxml .= '<QBXML>';
$qbxml .= '<QBXMLMsgsRq onError="stopOnError">';
$qbxml .= '<CustomerAddRq requestID="'.$requestID.'">';
$qbxml .= '<CustomerAdd>';
$qbxml .= '<Name>'.$this->Name.'</Name>'; //Name is a mandatory field. Add a check for this.
/** For all optional values add a check so that xml tags are not sent in request if value is blank**/
$qbxml .= '<CompanyName>'.$this->CompanyName.'</CompanyName>';
$qbxml .= '<FirstName>'.$this->FirstName.'</FirstName>';
$qbxml .= '<LastName>'.$this->LastName.'</LastName>';
$qbxml .= '<BillAddress>';
$qbxml .= '<Addr1>'.$this->BillAddress->get_Addr1().'</Addr1>';
$qbxml .= '<Addr2>'.$this->BillAddress->get_Addr2().'</Addr2>';
$qbxml .= '<City>'.$this->BillAddress->get_City().'</City>';
$qbxml .= '<State>'.$this->BillAddress->get_State().'</State>';
$qbxml .= '<PostalCode>'.$this->BillAddress->get_PostalCode().'</PostalCode>';
$qbxml .= '<Country>'.$this->BillAddress->get_Country().'</Country> ';
$qbxml .= '</BillAddress>';
$qbxml .= '<ShipAddress>';
$qbxml .= '<Addr1>'.$this->ShipAddress->get_Addr1().'</Addr1>';
$qbxml .= '<Addr2>'.$this->ShipAddress->get_Addr2().'</Addr2>';
$qbxml .= '<City>'.$this->ShipAddress->get_City().'</City>';
$qbxml .= '<State>'.$this->ShipAddress->get_State().'</State>';
$qbxml .= '<PostalCode>'.$this->ShipAddress->get_PostalCode().'</PostalCode>';
$qbxml .= '<Country>'.$this->ShipAddress->get_Country().'</Country> ';
$qbxml .= '</ShipAddress>';
$qbxml .= '<Phone>'.$this->Phone.'</Phone>';
$qbxml .= '<AltPhone>'.$this->AltPhone.'</AltPhone> ';
$qbxml .= '<Fax>'.$this->Fax.'</Fax> ';
$qbxml .= '<Email>'.$this->Email.'</Email> ';
//$qbxml .= '<JobDesc>Ob2</JobDesc>';
$qbxml .= '</CustomerAdd>';
$qbxml .= '</CustomerAddRq>';
$qbxml .= '</QBXMLMsgsRq>';
$qbxml .= '</QBXML>';
return $qbxml;
}

Ok I figured it out myself.
Alt+Enter then select Add <'tag'> to custom HTML tags.
Similar to how you handle words that come up as typos.

You can mark the string/var as a 'language injection':
Place the caret inside the string literal, tag, or attribute, in
which you want to inject a language and press Alt+Enter (or use the
intention action icon Intention action icon).
Select Inject language or reference and choose the language you want
to inject.
https://www.jetbrains.com/help/phpstorm/using-language-injections.html
The result looking like this:
$xmlString = /** #lang XML */
'<?xml version="1.0" encoding="utf-8" ?>';

Related

How to style a shortcode based on acf

I want to combine the output of an acf field from my page with my shortcode. The text should be underlined with the color set via an acf field.
I tried to call the field color and set the text-decoration via an inline style. But this is not working. Any ideas what I am doing wrong?
function quote_func($atts, $content = null){
$color = get_field('color');
$output = '<div>';
$output .= '<span style="text-decoration-color:' . echo the_field('color'); . '">' . $content . '</span>';
$output .= '</div>';
return $output;
}
add_shortcode( 'quote', 'quote_func' );
You should echo the variable you set in the beginning of your function.
function quote_func($atts, $content = null){
$color = get_field('color');
$output = '<div>';
$output .= '<span style="text-decoration-color:' . $color . '">' . $content . '</span>';
$output .= '</div>';
return $output;
}
add_shortcode( 'quote', 'quote_func' );
get_field('color') isn't enough to get the value if you're not inside a post, you need a second parameter. You are in a shortcode then you need to use:
get_field('color', $postId);
To get the id of the post from within shortcode you can use:
global $post;
$postId = $post->ID;
If you use the same color for each post you may have the option page and in that case you need to use:
get_field('color', 'option');

Sending php mail to csv list

Im trying to write a simple script to send a message to .csv list of e-mail addresses like this:
mail1#mail.com,
mail2#mail.com,
mail3#mail.com,
Here is what I have tried:
<?
$csv = array();
$file = fopen('test.csv', 'r');
while (($result = fgetcsv($file)) !== false){
$csv[] = $result;
$to = $result[0];
$subject = "My mail subject";
$message .= '<html><body>';
$message .= 'My message here';
$message .= "</body></html>";
$from = "example#example.com";
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
mail($to, $subject, $message, $headers);
}
fclose($file);
?>
But the message is sent three times, and includes the message three times in the body. How can I make the message only be included and sent one time to each line?
You should remove $subject, $message, $from and $headers definition from the while loop. Define all of them before and in the while define only the $to field and keep the mail() command.
Either follow the above suggestion (good approach) or simply remove concatenation operator "." form first assignment to variable $message i.e. change
$message .= '<html><body>'; TO
$message = '<html><body>';

How do I create a query that will insert large amounts of text special characters in MySQL

INFO: I am using [ MySQL 5.5.16 ]-[ PHP 5.3.8 ]-[ jqSajax 1.0.2 ]-[ JQuery 1.2.2 ]
PHP, MySQL, Apache and HTML header are charset UTF-8
I have been working on this for three days.
One database:
tblitems InnoDB
tblarticles MyISAM FULLTEXT
PROBLEM: I cannot insert a large amount of text with a simple insert because I have special characters ” “ ’ ‘ — …
QUESTION: How do I insert a large amount of text into a LONGTEXT field with special characters ” “ ’ ‘ — …
SEARCHED/TRIED: See code below and MySQL output at bottom
encode IN Javascript AJAX encodeURL()
decode IN PHP urldecode() to build SQL Query
CODE:
=========== create javascript ==========
<?php //calls php function through jqsajax
$strOnClickString = "$('#none').html(";
$strOnClickString .= '$.x_Add_Item(';
//$strOnClickString .= "$('#sel_txtPublication').val()"; //$strPublication
$strOnClickString .= "'Co-Worker Letters'"; //$strPublication
$strOnClickString .= ", $('#sel_txt_Title').val()"; //$strTitle
$strOnClickString .= ", $('#sel_txtMonth').val()"; //$strMonth
$strOnClickString .= ", $('#sel_txtYear').val()"; //$strYear
$strOnClickString .= ", $('#sel_txtAuthor').val()"; //$strAuthor
$strOnClickString .= ", encodeURI($('#strArticle').val())"; //$strArticle
$strOnClickString .= '))';
echo Create_Input('button','Submit Text','10','btnSubmit','btnSubmit','onclick',$strOnClickString); ?>
========= PHP create SQL ===========
//=========================================================================
function Add_Item($strPublication, $strTitle, $strMonth, $strYear, $strAuthor, $strArticle){
//=========================================================================
$sql1 = "";
$sql = "";
$sql1 = "INSERT INTO `hwa_archive`.`tblarticles`";
$sql1 .= "(`strArticle`)";
$sql1 .= " VALUES (";
if ($strArticle != 'ignore')
{
$sql1 .= '"' . urldecode($strArticle) . '", ';
}
$sql1 .= ")";
$sql1 = str_replace('", )','" )',$sql1);
$res2 = mysql_query($sql1);
//$res2 = mysql_query('SELECT LAST_INSERT_ID()');
$intArticle_ID = mysql_insert_id();
$sql = "INSERT INTO `hwa_archive`.`tblitems`";
$sql .= "(`strPublication`, `strTitle`, `strMonth`, `strYear`, `strAuthor`, `intArticle_ID`)";
$sql .= " VALUES (";
if ($strPublication != 'ignore')
{
$sql .= "'$strPublication', ";
}
if ($strTitle != 'ignore')
{
$sql .= "'$strTitle', ";
}
if ($strMonth != 'ignore')
{
$sql .= "'$strMonth', ";
}
if ($strYear != 'ignore')
{
$sql .= "'$strYear', ";
}
if ($strAuthor != 'ignore')
{
$sql .= "'" . $strAuthor . "', ";
}
$sql .= "'$intArticle_ID', ";
$sql .= ")";
$sql = str_replace("', )","' )",$sql);
$res2 = mysql_query($sql);
Return $intArticle_ID . "<br /><br />" . $sql . "<br /><br />" . $sql1;
}
MySQL OUTPUT:
YOUR Part in the World’s Network (’ needs to be a single curly quote ’)
YOUR Part in the World%u2019s Network (%u2019 needs to be a single curly quote ’) no decode in add_item
I hope this info is not overkill.

PHPMyAdmin LaTeX-export doesn't show row comments

I'm trying to export my database tables to LaTeX in PHPMyAdmin. It does generate a "comments" column, but nothing is put in there eventhough I do have comments for several fields of the table I'm trying to export. (and of course I do have the "comments"-checkbox checked). Does anybody know a solution to this, or is this simply a bug in (this version of) PHPMyAdmin?
I'm using MySQL 5.5.9 with PHPMyAdmin version 3.3.9.2.
I decided to solve the problem by myself by writing the following PHP-script. It makes LaTeX-tables from all MySQL tables in the database, with a Field column for the row name, and a Description column for the comments. The code does not contain the MySQL connection logic. It can be a nice addition in your documentation to the graphical schemes that can be made with MySQLWorkbench. For good displaying in a web browser, use nl2br().
function showDescriptions(){
$result = "";
$tables = mysql_query("SHOW TABLES");
while($table = mysql_fetch_row($tables)){
$columns = mysql_query("SHOW FULL COLUMNS FROM `".$table[0]."`");
$result .= "\begin{table}[h!] %b!p!\n";
$result .= '\begin{tabular}{|p{0.3\textwidth}|p{0.63\textwidth}|}'."\n";
$result .= "\hline\n";
$result .= "Field & Description\\\\\n";
$result .= "\hline \hline\n";
while($column = mysql_fetch_array($columns)){
$result .= LaTeXSafe($column['Field']);
$result .= " & ";
$result .= LaTeXSafe($column['Comment']);
$result .= "\\\\\n";
$result .= "\hline\n";
}
$result .= '\end{tabular}'."\n";
$result .= '\vspace{-7pt}'."\n";
$result .= '\caption{\textit{Field descriptions of table '.$table[0].'}}'."\n";
$result .= '\vspace{-7pt}'."\n";
$result .= '\label{table-'.$table[0].'}'."\n";
$result .= '\end{table}'."\n\n\n";
}
return $result;
}
function LaTeXSafe($text){
return str_replace("_", "\_", $text);
}
I hope it's useful to someone.

How to design html timetable

I'm currently working on a project where I need to print out a lesson timetable. Here is a link to the one I have created http://conorhackett.com/tt/.
It works fine now but i'd like to have more control over it. If you look at the code you'll see what I mean. The html/css is very messy.
I've tried to do it with a html table but it didn't look great with all the lines.
Is there any foundations available to me that I could use as a base.?
Any adive greatly appreciated :)
--Conor
Update:
Hi Guys,
I've decided to go back to a html table. I am having extreme difficulty getting my head around the logic used to print the data.
Here is my code for printing the table:
foreach($bookingList->result_array() as $row)
{
$time = $row['start_time']. ' - ' .$row['end_time'];
$lesson = $row['lesson_type_name'];
$client = $row['client_firstname']. ' ' .$row['client_lastname'];
$horse = $row['horse_name'];
$fee = $row['fee'];
if(empty($prevLesson) && empty($prevTime))
{
echo '1';
$timeArr .= $time;
$lessonArr .= $lesson;
$clientArr .= $client;
$horseArr .= $horse;
$feeArr .= $fee.'-'.$i;
}
elseif($prevLesson == $lesson && $prevTime == $time)
{
echo '3';
echo '<br/>Previous: '.$prevTime.'++'.$prevLesson.'-'.$i.'<br/>';
echo '<br/>Current: '.$time.'++'.$lesson.'-'.$i.'<br/>';
$timeArr .= $time;
$lessonArr .= $lesson;
$clientArr .= $client;
$horseArr .= $horse;
$feeArr .= $fee.'-'.$i;
}
else
{
echo '3';
echo '<tr>';
echo '<td>(3)'. $timeArr .'</td>';
echo '<td>'. $lessonArr .'</td>';
echo '<td>'. $clientArr .'</td>';
echo '<td>'. $horseArr .'</td>';
echo '<td>'. $feeArr.'</td>';
echo '<td>'. $i.'</td>';
echo '</tr>';
$timeArr = ' ';
$lessonArr = ' ';
$clientArr = ' ';
$horseArr = ' ';
$feeArr = ' ';
$optionsArr = ' ';
$timeArr .= $time.'<br/>';
$lessonArr .= $lesson.'<br/>';
$clientArr .= $client.'<br/>';
$horseArr .= $horse.'<br/>';
$feeArr .= $fee.'-'.$i.'<br/>';
}
$prevTime = $time;
$prevLesson = $lesson;
$i += 1;
}
The idea for printing is:
Read data from DB and store in a string. when the data changes (time and lesson type) print the stored string, clear it and assign the new (different data) to the print string.
I have put up the code as is.. i'm just so frustrated and tired now. I have spent 3 hourse every evening this week trying to complete and have failed every time.. If you are willing to help me and need more detailed just let me now..
Any help really appreciated..
Thanks.
Give tables another shot, using this:
table {
border-collapse: collapse;
}
In addition to Amadan's suggestion, consider using colspan and rowspan to make each box take up the space required. Review the source code on these examples to see what I mean.
Soln: After the foreach loop had finished I still had data in the print string. I just echo that after the foreach loop and it solved everything. Thanks for the help input guys.