I'm currently editing a website, and I have a couple of small snags I've hit. In this .php file that I'm editing, I'm changing some language to Portugese, I have it typed below with english characters, but once I add special characters like Ç or à my plugin dies (I mean I get a spinning wheel for loading, and it never loads). This is for a plugin in wordpress.
<div id="label_gen_info">' .
'Informacao Geral' .
'</div>'.'<div>' .
'<table>' .
'<tr>' .
'<td>Endereco :</td>' .
'<td>{1}</td>' .
'</tr>' .
'<tr>' .
'<td></td>' .
'<td>{2}</td>' .
'</tr>' .
'<tr>' .
'<td></td>' .
'<td>{6}</td>' .
'</tr>' .
'<tr>' .
'<td style="width:115px">Telefone :</td>' .
'<td>{14}</td>' .
'</tr>' .
'<tr>' .
'<td>Horario De Funcionamento :</td>' .
'<td>{7}</td>' .
'<td>{11}</td>' .
'</tr>' .
'<tr>' .
'<td></td>' .
'<td>{8}</td>' .
'<td>{12}</td>' .
'</tr>' .
'<tr>' .
'<td></td>' .
'<td>{9}</td>' .
'<td>{13}</td>' .
'</tr>' .
'<tr>' .
'<td></td>' .
'<td>{10}</td>' .
'</tr>' .
'<tr>' .
'<td>Horario De Compras :</td>' .
'<td>{15}</td>' .
'</tr>' .
'</table>' .
'</div>' .'</div>' .
Also, I'm trying to edit the format, but I'm not sure what the {15} (what the {15} actually does) does, so I didn't want to just change things around without knowing first. Any help is appreciated, thanks.
Alright, so as posted in other places on this forum, my language needed to be set to UTF-8 instead of ASCII. I'm not entirely sure how to do that, but the instructions on that are a little out of the scope for this question, so I'll leave it to my own research. To answer the second question, the {15}, and other numbers still confuse me a little, but they apparently are similar to variable calls, since when I changed them, the variables in their places changed. If anyone wants to clear that up a little bit more, feel free, but for now this is enough of an answer for me (although I'll still be looking into php more, since I'm still a novice.)
Related
I haven't used regex in a long time and can't figure out how to match an actual dollar symbol and any reference to dollar symbol and regex tells me about the special meanings and cases. I need to match a $. I expected that \$ or $$ was supposed to escape it, but I'm still not matching it.
Here's my text
(WW) Capacity Charge
. . . . . . . . . . . . . . . . $ 123.45
WW Commodity Charge . . . . . . . . . $ 67.89
I'm trying to capture 123.45 I figured I should just match the first occurrence where some characters are sandwiched between the dollar symbol, space and a newline. Here are a few of the regexes I've tried.
preg_match("|(?<=\$\s)(.*)(?=\n)|",$data[1],$matches); //no matches
preg_match("|(?<=$\s)(.*)(?=\n)|",$data[1],$matches); //no matches
preg_match("|(?<=$)(.*)(?=\n)|",$data[1],$matches); //no matches
preg_match("|(?<=\$)(.*)(?=\n)|",$data[1],$matches); //no matches
preg_match("|(?<=$$)(.*)(?=\n)|",$data[1],$matches); //no matches
Just to check that something matches I even did
preg_match("|(?<=\.)(.*)(?=\n)|",$data[1],$matches); // . . . . . . . . . . . . . . . $ 123.45
preg_match("|(?<=.)(.*)(?=\n)|",$data[1],$matches); // . . . . . . . . . . . . . . . $ 123.45
preg_match("|(?<=1)(.*)(?=\n)|",$data[1],$matches); // 23.45
How can I match the text between the $ and the newline?
You are in double quotes so you need to escape twice (once for PHP, then once for PCRE). I prefer a character class though because that works in all regex flavors.
(?<=[$]\s)(.*)(?=\n)
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 5 years ago.
I can's seem to figure out why I'm getting this error.
I need to turn user_link part into hyperlink(right now it outputs a text on the frontend). Error happens on this line in my shortcode.php file. I guess there is an error with a href part:
$output .= '<td>' . $order->billing_first_name . ' ' . $order->billing_last_name . ' <a href='" . $order->user_link . "'>" . $order['user_link'] . "</a> </td>';
Your issue is right here:
. ' <a href='" .
Notice how you're starting with a single quote and ending with a double.
Definitely consider using an IDE. It will make these easy bugs blatantly obvious. I highly recommend PHPStorm, or if you don't want to spend anything, sublime text (Not an IDE but will provide linting and highlighting).
On top of that I'd recommend using some type of templating engine eventually. You should always try to avoid writing HTML as strings.
$output .= '<td>' . $order->billing_first_name . ' ' . $order->billing_last_name . ' ' . $order['user_link'] . ' </td>';
You switched the ' and " in the a href. I also changed the two " to ' in the a description.
Hi straight forward question really. I have a search function in php that prints out the required information from a data base. But it prints it out as one word. I don't want a line break...just a space between words. I've googled and checked this forum for answers but can't seem to find any.
The code works and does as it is required but it doesn't look neat.
Instead of: ID Job Title Job Description Job location Job Category
it looks like this:
IDJobTitleJobDescriptionJoblocationJobCategory
This is part of my php code.
// $results = mysql_fetch_array($raw_results) puts data from database into array, while it's valid it does the loop
echo
'<p>'
. $results['id']
. $results['job_title']
. $results['job_description']
. $results['job_location']
. $results['job_category']
. '</p>';
Please note I want it in one line, not line breaks. Thanks.
You have to echo the space like this .' '.
Or in your Case just replace your code with this.
echo
'<p>'
. $results['id']
.' '. $results['job_title']
.' '. $results['job_description']
.' '. $results['job_location']
.' '. $results['job_category']
.' '. '</p>
echo '<p>'
.$results['id'] . ' '
. $results['job_title'] . ' '
. $results['job_description'] . ' '
. $results['job_location'] . ' '
. $results['job_category'] . ' '
. '</p>';
I am having a problem trying to get a row to create everytime I enter a new database entry.
My code so far is:
<table align="center">
<th>MH/s</th><th>Contact Length</th><th>Date Bought</th><th>Payment</th>
<?php while ($row_cnt > 0) {
echo "<tr><td>" . $row['mhbought'] . "</td><td>" . $row['length'] . "</td><td>" . date(d-m-Y, $row['datebought'] . "</ td><td>" . $row['payment'] . "</td></tr>";
}
?>
</table>
The error I receive however states PHP Parse error: syntax error, unexpected ';' (which is the echo line) Am I doing something completely dumb here, can this even be done?
Thank you for any help you may provide.
Looking at the code, the problematic line is this:
date(d-m-Y, $row['datebought']
^^ missing quotes ^ missing closing parenthesis
Change it to:
date('d-m-Y', $row['datebought'])
You haven't close date() right bracket and there is quotation missing for date format. Your echo should look like:
echo "<tr><td>" . $row['mhbought'] . "</td><td>" . $row['length'] . "</td><td>" . date('d-m-Y', $row['datebought']) . "</td><td>" . $row['payment'] . "</td></tr>";
I want to create an HTML Message to send an email in PHP.
$message = $mess0 . "</br>" . $mess1 . "</br>" . $mess2 . "</br>" . $mes1 . "</br></br>" . $mes2 . "</br>" . $mes23 . "</br></br>" . $mes3 . "</br></br>" . $mes4 . "</br>" . $mes5 . "</br>" . $mes6 . "</br>" . $mes7 . "</br>" . $mes8 . "</br>" . $mes9 . "</br></br>" . $mes10 ;
$message = <html><body><p>$message</p></body></html>;
Here are some variables.
I am getting the following error.
Parse error: syntax error, unexpected '<' in /home/thevowaa/public_html/iphoneapp/webservice/file.php on line 214
Add HTML tags between double quotes.
$message = "<html><body><p>".$message."</p></body></html>";
Where are the double quotes see below
$message = "<html><body><p>$message</p></body></html>";
There are two possible ways to hold HTML in PHP variable. You can use single quote or double quotes. You also need to put a dot(.) before and after single/double quotes. Your PHP string could be constructed in following two ways:
$message = '<html><body><p>'.$message.'</p></body></html>';
or like this,
$message = "<html><body><p>".$message."</p></body></html>";
Also, use of single quotes(') is encouraged in PHP coding because it's doesn't clash with javascript or css double quotes(") when constructing html pages using PHP.
For more information on usage of quotes in PHP, check out this stackoverflow answer