Parse error: syntax error, unexpected end of file plzz help me find out whats the error? - parsing

0){
while ($row=mysqli_fetch_array($res))
{
$Name=$row['Name'];
$Link=$row['Link'];
?>
">
0){
while ($row=mysqli_fetch_array($res))
{
$submenu=$row['submenu'];
?>

Please share a bigger snippet of code. This error usually happens when there is a typing mistake or not closing php tags. Make sure your <?php ?> tags are opening and closing correctly and check if you are using shorthand tags like this <? } ?> If you are using it please avoid that. Also make sure that you are not mixing PHP opening and closing tags with }?> make sure there is a space between php opening and closing tags.

Related

phpcs require alternative syntax in html files

I want to require alternative syntax in controle structure within html files , otherwise, throw error or warning if alternative syntax rules not been respected in whatever instruction .
Below is an example of alternative syntax that should be established:
<?php if (true === $var) : ?>
<h3>Hello world</h3>
<?php else : ?>
<h3>Hello</h3>
<?php endif; ?>
Is there a phpcs sniff which deals with such requirements ? if not , how can we make a customized sniff to check for alternative syntax in html files ?

How to send the PDF output to browser print option (CTRL+P)

I am using TCPDF library to generate some reports, and i want to send the PDF file to print option of browser as simple we press CTRL+P, I need this because it is slip.
I used all parameter for Output but it is downloading the file directly.
$pdf->Output('slip.pdf', 'I');
I also placed the F,D,S,E,FI and FD instate of I but it doesn't work. And I also used header
header('Content-Type: application/pdf');
$pdf->Output('example_001.pdf', 'FD');
but again it doesn't work. Any solution? Please!
Add
$pdf->IncludeJS("print();");
just before $pdf->Output...
You need something like the example below. You would need to intercept print request (print automatically on page load, print button click, etc.) and then call printTrigger function.
<html>
<head>
<title>Print PDF</title>
<script>
function printTrigger(elementId) {
var getMyFrame = document.getElementById(elementId);
getMyFrame.focus();
getMyFrame.contentWindow.print();
}
</script>
</head>
<body>
<iframe id="iFramePdf" src="http://pdfurl.com/sample.pdf"></iframe>
...
</body>
</html>
What you are trying to do is not within the specification of the TCPDF API.
http://www.tcpdf.org/doc/code/classTCPDF.html#a3d6dcb62298ec9d42e9125ee2f5b23a1
I believe you would need to use JavaScript to implement this feature the way you are proposing.
Add $pdf->IncludeJS("print();"); just before $pdf->Output...
It's working for me.

PHP include outside url

When trying to include a php file into another it either does nothing at all (no errors). If i require it will give a useless message
"Failed opening required 'http://example.org.com/xxx.php' (include_path='.:/usr/local/php5/lib/php')
<div id="menu"> <?php include("http://www.sitename.com/menu.php") ?> </div>
The file im trying to include is on the same site and host.
The page im including from is:
root/wiki/skin/index.php (mediawiki)
menu.php is located:
root/menu.php
since mediawiki treats the /wiki/ path as the root i cannot back out with ../../ etc.
What am i doing wrong here? Thanks
Sir, try this:
<div id="menu"> <?php include("../../menu.php") ?> </div>
To include URLs in your PHP project you must have enabled (true) this option:
allow_url_include
in your php.ini configuration. More information you can find here:
http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-include

SimplePie RSS Parser - Encoding and Weird Characters even on UTF-8

I am using SimplePie to Parse an RSS feed, and I am getting the following output:
Don't forget our "Spot It, Post It" .....
My code is:
<?php
header('Content-type:text/html; charset=utf-8');
require_once('rss/simplepie.inc');
// We'll process this feed with all of the default options.
$feed = new SimplePie();
// Set which feed to process.
$feed->set_feed_url('FeedURL');
$feed->enable_cache(true);
$feed->set_cache_duration(3600);
$feed->set_cache_location('cache');
$feed->init();
$feed->handle_content_type();
?>
I'm using HTML5 Doctype AND I also have: <meta charset="charset=utf-8">
I've looked it up and everything talks about changing the charset to UTF-8 which I clearly have.. so I'm not too sure what else is causing this.
Any ideas?
I don't know if you've managed to fix this, but thought I'd share my solution with anyone else who is looking. I had the same problem - the characters were being 'corrupted' in the feed. My code initially (with the problem) was:
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/inc/simplepie.inc';
$feed = new SimplePie('http://domain.wordpress.com/feed/');
?>
Seeing the post above, I tried adding the following header and it worked!
<?php
header('Content-type:text/html; charset=utf-8');
include_once $_SERVER['DOCUMENT_ROOT'] . '/inc/simplepie.inc';
$feed = new SimplePie('http://domain.wordpress.com/feed/');
?>
I hope this helps someone else experiencing the same problems.
Does this happen with every feed? Or just one particular feed? It might be the feed itself. You can use $item->get_content() and look at the content of the feed directly if the description itself is proving problematic. Sometimes it is necessary to do processing on information from a feed or web API, there is PHP code and examples for stripping and replacing characters, the News Blocks 2.0 demo on the SimplePie site has some cleaning code I've been using a lot recently.
Good luck.

MODX: Snippet strips and hangs string when parsing the vars

i have a snippet call like this:
[!mysnippet?&content=`[*content*]` !]
What happen is that, if i send some html like this:
[!mysnippet?&content=`<p color='red'>Yeah</p>` !]
it will return this:
<p colo
the [test only] snippet code (mysnippet) is:
<?php
return $content;
?>
Why is this happening?
My actual snippet is converting html to pdf, so i really need this.
Thank you all ;D
EDIT: I'm using Modx Evo 1.0.2
MODx Evolution has a limitation whereby you can't use "=" (equals signs) in Snippet parameter values. Best solution is to place the content in a chunk or TV and then call it. This is not an issue in MODx Revolution.

Resources