preg match not reading content between table - preg-match

preg_match_all('|<table cellspacing="0" cellpadding="0" summary="Flight Timetable search results" id="timeTable">(.*?)</table>|', $read, $foo, PREG_SET_ORDER);
print_r($foo);
output as just
Array ( )
Where i made mistake
See guys ,
Actually i want to grab the exact details from this URL
i want to pick this details from this URL
08:35 9W5048 TORONTO EXPECTED 1358 Terminal three
So i tried this snippet , but it throwing Error like
this is my snippet
$read = file_get_contents("http://www.heathrowairport.com/portal/site/heathrow/template.PAGE/menuitem.a43f3a72926ca3b1b0c52a499328c1a0/?javax.portlet.begCacheTok=token&javax.portlet.endCacheTok=token&javax.portlet.tpst=bde211e38117ef94303fde9faca12635&javax.portlet.prp_bde211e38117ef94303fde9faca12635_flightRoute=&javax.portlet.prp_bde211e38117ef94303fde9faca12635_flightNumber=9W5048&javax.portlet.prp_bde211e38117ef94303fde9faca12635_flightTerminal=");
//echo $read;
preg_match_all('/(.?)</table>/si', $read, $foo, PREG_SET_ORDER);
$read1 = $foo[0][0];
preg_match_all('/(.?)</tbody>/si', $read1, $foo1, PREG_SET_ORDER);
print_r($foo1[0][0]);
I got Error like
Notice: Undefined offset: 0 in E:\wamp\www\plugin\read-airport-arraiwals.php on line 6
Notice: Undefined offset: 0 in E:\wamp\www\plugin\read-airport-arraiwals.php on line 8

preg_match_all('/timeTable" .*<tbody>(.*?)<\/table>/smU', $read, $foo, PREG_SET_ORDER);
preg_match_all('/<(th|td).*>(.*)<\/(th|td)>/smU', $foo[0][1], $result, PREG_SET_ORDER);
print_r($result);
And you will get the required data. Quick answer because I don't have time to create a single pattern for that, but this one will do the job.

Related

Tracing execution of Lua Sripts

I know you can use the debug library of lua to get some tracing info/debugging. But the information is in pieces. So I am wondering if there is a way to trace the execution of a Lua script. A step by step process. it would be required and it will automatically go thru at every execution step To produce a report such as the following;
Called: function xyz from : Table abc
It has n parameters
Param 1: apples
Param 2: oranges
.
.
It has m returns
return 1: red
return 2: yellow
.
.
Called: function xyz2 from : Table abc2
It has n parameters
Param 1: pears
Param 2: bananas
.
.
It has m reruns
return 1: heavy
return 2: light
.
.
and so on....
Here is some code that used to be distributed in the Lua tarball. It's from 2005 and still works fine.
-- trace calls
-- example: lua -ltrace-calls bisect.lua
local level=0
local function hook(event)
local t=debug.getinfo(3)
io.write(level," >>> ",string.rep(" ",level))
if t~=nil and t.currentline>=0 then io.write(t.short_src,":",t.currentline," ") end
t=debug.getinfo(2)
if event=="call" then
level=level+1
else
level=level-1 if level<0 then level=0 end
end
if t.what=="main" then
if event=="call" then
io.write("begin ",t.short_src)
else
io.write("end ",t.short_src)
end
elseif t.what=="Lua" then
io.write(event," ",t.name or "(Lua)"," <",t.linedefined,":",t.short_src,">")
else
io.write(event," ",t.name or "(C)"," [",t.what,"] ")
end
io.write("\n")
end
debug.sethook(hook,"cr")
level=0

I Have 2 1064 SQL Errors And Can Not Figure Them Out

This code worked good on ph 5.3. My server got upgraded to php5.6 and now the code no longer works.
Here is the two statements.
$sql = "UPDATE " . FORUM_TOUR_TABLE . "
SET page_subject = '$subject', page_text = '$message', page_access = $page_access
WHERE page_id = $id";
It says :
`SQL Error : 1064 Syntax error near 'WHERE page_id = 1' at line 3
UPDATE SET phpbb_forum_tour page_subject = ' Welcome To The Tower' , page_text = ' Update me please ' = WHERE page_access page_id = 1
Line : 172
File: admin_forum_tour.php`
That happens when I try to update a post.
When I try to add a new post using this code:
$sql = "INSERT INTO " . FORUM_TOUR_TABLE . " (page_id, page_subject, page_text, page_sort, bbcode_uid, page_access)
VALUES ($id, '$subject', '$message', $page, '$bbcode_uid', $page_access)";
This gives me this:
`SQL Error : 1064 Syntax error near ')' at line 2
INSERT INTO phpbb_forum_tour ( page_id , page_subject , page_text , page_sort , bbcode_uid , page_access ) VALUES (3, '2 Word Rule ', ' Hello World I am here ', 30 , ' f4e1be18dc ' )
Line : 198
File: admin_forum_tour.php`
I 100% apologize for asking this as I am more than sure it has been beat to death. I have been searching for a couple hours now and have all but given up. I had it working once but was told I opened my self up to injection. I am not a pro coder. I get lucky sometimes and make things work. I am sure these errors and code is basic to most but I am still learning.
Thanks for helping and understanding my "newbieness".

php info gives me error_reporting local value 4177 [duplicate]

In my local dev env, I use PHP Version 5.3.3-1ubuntu9.2.
Now when I see error_reporting, the value is 22527.
What is 22527?
I checked http://www.php.net/manual/en/errorfunc.constants.php, but I could not find the number.
Could anyone tell me what it is?
Do I need to change it to E_ALL | E_STRICT ?
Thanks in advance.
This value is actually bitmap mask, a sum of constants.
So, 22527 is
16384 E_USER_DEPRECATED
+
4096 E_RECOVERABLE_ERROR
+
etc...
In your case it's E_ALL & ~E_DEPRECATED, it will display every error, except E_DEPRECATED.
PHP versions below 5.4 will also exclude E_STRICT errors (since E_STRICT is not included in E_ALL before that version)
This value is one or more of these constants bitwise-ored together.
phpinfo() usually displays the numeric value instead of the constants or shorthands used inside INI files. Here is an example to map the value back to constants:
<?php
$error_reporting_value = 22527;
$constants = array(
"E_ERROR",
"E_WARNING",
"E_PARSE",
"E_NOTICE",
"E_CORE_ERROR",
"E_CORE_WARNING",
"E_COMPILE_ERROR",
"E_COMPILE_WARNING",
"E_USER_ERROR",
"E_USER_WARNING",
"E_USER_NOTICE",
"E_STRICT",
"E_RECOVERABLE_ERROR",
"E_DEPRECATED",
"E_USER_DEPRECATED",
"E_ALL"
);
$included = array();
$excluded = array();
foreach ($constants as $constant) {
$value = constant($constant);
if (($error_reporting_value & $value) === $value) {
$included[] = $constant;
} else {
$excluded[] = $constant;
}
}
echo "error reporting " . $error_reporting_value . PHP_EOL;
echo "includes " . implode(", ", $included) . PHP_EOL;
echo "excludes " . implode(", ", $excluded) . PHP_EOL;
Output:
error reporting 22527
includes E_ERROR, E_WARNING, E_PARSE, E_NOTICE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE, E_RECOVERABLE_ERROR, E_USER_DEPRECATED
excludes E_STRICT, E_DEPRECATED, E_ALL
NEVER use the numeric value to set your error reporting, as the meaning of that value can change but the meaning of the constants (like E_ALL, E_STRICT, etc) likely will not:
The new error_reporting level. It takes on either a bitmask, or named constants. Using named constants is strongly encouraged to ensure compatibility for future versions. As error levels are added, the range of integers increases, so older integer-based error levels will not always behave as expected.
(and note that as of PHP 5.4, E_ALL now includes E_STRICT)
IF you want the strictest reporting forever and ever, you could set error_reporting to a very large number in order to guarantee(?) that you will report all errors forever :
Using PHP Constants outside of PHP, like in httpd.conf, will have no useful meaning so in such cases the integer values are required. And since error levels will be added over time, the maximum value (for E_ALL) will likely change. So in place of E_ALL consider using a larger value to cover all bit fields from now and well into the future, a numeric value like 2147483647 (includes all errors, not just E_ALL).
Check your php.ini for the value of error_reporting in human-readable PHP constants format. The phpinfo() function appears to always show the numeric value rather than showing the constants.
But, personally, I leave php.ini with the default values for error reporting. Instead I just put the error reporting function at the top of whatever php script I'm working on to override the defaults. e.g.:
error_reporting(E_ALL | E_STRICT);
$ php -i | grep error_reporting
o/p is 22527
Go To
https://maximivanov.github.io/php-error-reporting-calculator/
Enter 22527 in Resulting Error Level box.
O/p is E_ALL & ~E_STRICT & ~E_DEPRECATED
OR
$arr = array_flip(array_slice(get_defined_constants(true)['Core'], 0,15));
$needToRemove = array('E_ALL','E_STRICT','E_DEPRECATED');
$filtered = array_diff($arr, $needToRemove);
print_r($filtered);
echo array_sum(array_flip($filtered));
o/p is
Array
(
[1] => E_ERROR
[4096] => E_RECOVERABLE_ERROR
[2] => E_WARNING
[4] => E_PARSE
[8] => E_NOTICE
[16] => E_CORE_ERROR
[32] => E_CORE_WARNING
[64] => E_COMPILE_ERROR
[128] => E_COMPILE_WARNING
[256] => E_USER_ERROR
[512] => E_USER_WARNING
[1024] => E_USER_NOTICE
[16384] => E_USER_DEPRECATED
)
22527

CT_FETCH error in PowerBuilder Program

I'm still learning PowerBuilder and trying to get familiar with it. I'm receiving the following error when I try to run a program against a specific document in my database:
ct_fetch(): user api layer: internal common library error: The bind of result set item 4 resulted in an overflow. ErrCode: 2.
What does this error mean? What is item 4? This is only when I run this program against a specific document in my database, any other document works fine. Please see code below:
string s_doc_nmbr, s_doc_type, s_pvds_doc_status, s_sql
long l_rtn, l_current_fl, l_apld_fl, l_obj_id
integer l_pvds_obj_id, i_count
IF cbx_1.checked = True THEN
SELECT dsk_obj.obj_usr_num,
dsk_obj.obj_type,
preaward_validation_doc_status.doc_status,
preaward_validation_doc_status.obj_id
INTO :s_doc_nmbr, :s_doc_type, :s_pvds_doc_status, :l_pvds_obj_id
FROM dbo.dsk_obj dsk_obj,
preaward_validation_doc_status
WHERE dsk_obj.obj_id = :gx_l_doc_obj_id
AND preaward_validation_doc_status.obj_id = dsk_obj.obj_id
using SQLCA;
l_rtn = sqlca.uf_sqlerrcheck("w_pdutl095_main", "ue_run_script", TRUE)
IF l_rtn = -1 THEN
RETURN -1
END IF
//check to see if document (via obj_id) exists in the preaward_validation_doc_status table.
SELECT count(*)
into :i_count
FROM preaward_validation_doc_status
where obj_id = :l_pvds_obj_id
USING SQLCA;
IF i_count = 0 THEN
//document doesn't exist
// messagebox("Update Preaward Validation Doc Status", + gx_s_doc_nmbr + ' does not exist in the Preaward Validation Document Status table.', Stopsign!)
//MC - 070815-0030-MC Updating code to insert row into preaward_validation_doc_status if row doesn't already exist
// s_sql = "insert into preaward_validation_doc_status(obj_id, doc_status) values (:gx_l_doc_obj_id, 'SUCCESS') "
INSERT INTO preaward_validation_doc_status(obj_id, doc_status)
VALUES (:gx_l_doc_obj_id, 'SUCCESS')
USING SQLCA;
IF sqlca.sqldbcode <> 0 then
messagebox('SQL ERROR Message',string(sqlca.sqldbcode)+'-'+sqlca.sqlerrtext)
return -1
end if
MessageBox("PreAward Validation ", 'Document number ' + gx_s_doc_nmbr + ' has been inserted and marked as SUCCESS for PreAward Validation.')
return 1
Else
//Update document status in the preaward_validation_doc_status table to SUCCESS
Update preaward_validation_doc_status
Set doc_status = 'SUCCESS'
where obj_id = :l_pvds_obj_id
USING SQLCA;
IF sqlca.sqldbcode <> 0 then
messagebox('SQL ERROR Message',string(sqlca.sqldbcode)+'-'+sqlca.sqlerrtext)
return -1
end if
MessageBox("PreAward Validation ", 'Document number '+ gx_s_doc_nmbr + ' has been marked as SUCCESS for PreAward Validation.')
End IF
update crt_script
set alt_1 = 'Acknowledged' where
ticket_nmbr = :gx_s_ticket_nmbr and
alt_2 = 'Running' and
doc_nmbr = :gx_s_doc_nmbr
USING SQLCA;
Return 1
ElseIF cbx_1.checked = False THEN
messagebox("Update Preaward Validation Doc Status", 'The acknowledgment checkbox must be selected for the script to run successfully. The script will now exit. Please relaunch the script and try again . ', Stopsign!)
Return -1
End IF
Save yourself a ton of headaches and use datawindows... You'd reduce that entire script to about 10 lines of code.
Paul Horan gave you good advice. This would be simple using DataWindows or DataStores. Terry Voth is on the right track for your problem.
In your code, Variable l_pvds_obj_id needs to be the same type as gx_l_doc_obj_id because if you get a result, it will always be equal to it. From the apparent naming scheme it was intended to be long. This is the kind of stuff we look for in peer reviews.
A few other things:
Most of the time you want SQLCode not SQLDbCode but you didn't say what database you're using.
After you UPDATE crt_script you need to check the result.
I don't see COMMIT or ROLLBACK. Autocommit isn't suitable when you need to update multiple tables.
You aren't using most of the values from the first SELECT. Perhaps you've simplified your code for posting or troubleshooting.

How to resize images from URL directly

http://example.com/unsafe/184x147/top/http://www.example.com/abc.jpg
In the link above the image is resized from url by passing the image dimensions , position , and source image .
Can someone please explain what is the process that is actually happening here ?
for example :
http://www.example.com/variable1/variable2/variable3
You might find it easier to grab the parameters in the .php file, via:
$pathinfo = isset($_SERVER['PATH_INFO'])
? $_SERVER['PATH_INFO']
: $_SERVER['REDIRECT_URL'];
$params = preg_split('|/|', $pathinfo, -1, PREG_SPLIT_NO_EMPTY);
echo "<pre>";
print_r($params);
would return:
Array
(
[0] => variable1
[1] => variable2
[2] => variable3
)
see this

Resources