query Reg: warning
Moderator: General Moderators
query Reg: warning
hi
i got following warning in my site warning:Variable passed to each() is not an array or object in php,
please let me know the reason
awaiting for your valuable answers
thank you
regards
sujith
i got following warning in my site warning:Variable passed to each() is not an array or object in php,
please let me know the reason
awaiting for your valuable answers
thank you
regards
sujith
Pimptastic | Please use
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
thank u for your quick reply ,here is my code .........Code: Select all
while(list($key, $val)=each($tc['one_res']))
{
$report[$val['brand_name']][$val['material_no']]['one_qty']=$val['qtysum'];
}Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]What version of PHP are you using? if it's at least version 4, you can use foreach instead of each... so the syntax would look like:
Code: Select all
if(is_array($tc['one_res'])){
foreach($tc['one_res'] as $val)
{
$report[$val['brand_name']][$val['material_no']]['one_qty']=$val['qtysum'];
}
}
else{
echo "Could not iterate results, because tc is not an array!";
print_r($tc); // Print what it is so you can figure out why it wasn't an array
}Pimptastic | Please use
i got a following warning
Warning: preg_match() [function.preg-match]: Unknown modifier 'P' in D:\Program Files\www\Tester\search.php on line 233
A match was not found.
plz let me know the solution
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hey i have one more issues that isCode: Select all
$pattern='**SPEAKERNAME**';
if (preg_match($pattern,$source))
{ echo "A match was found.";
} else {
echo "A match was not found.";
}i got a following warning
Warning: preg_match() [function.preg-match]: Unknown modifier 'P' in D:\Program Files\www\Tester\search.php on line 233
A match was not found.
plz let me know the solution
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Pimptastic | Please use
but i got a warning like .............
Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 0 in D:\Program Files\www\Tester\search.php on line 233
A match was not found.
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hi
i put like ...........Code: Select all
$pattern='#**SPEAKERNAME**#';
if (preg_match($pattern,$source))
{ echo "A match was found.";
} else {
echo "A match was not found.";
}Warning: preg_match() [function.preg-match]: Compilation failed: nothing to repeat at offset 0 in D:\Program Files\www\Tester\search.php on line 233
A match was not found.
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
ok 1st thing i will say is perdy please use the php / code tags when posting code. it makes it much easier to read.
second, i don't know much about regular expressions (preg_match stuff) but why not just use strpos?
its much easier if you are just looking for a string and not a pattern. also note how perdy that code looks 
second, i don't know much about regular expressions (preg_match stuff) but why not just use strpos?
Code: Select all
$pattern = '**SPEAKERNAME**';
if (false !== strpos($source, $pattern))
{
echo 'a match was found';
}
else
{
echo 'no matches found';
}Pimptastic | Please use
thank u very much and esp for ur quick responce ,God Bless u all
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
ok i will carry on ur instructions ,and i got a solution byCode: Select all
<?php
$pattern='**SPEAKERNAME**';
if (stristr($source,$pattern))
{ echo "A match was found.";
} else {
echo "A match was not found.";
}
?>thank u very much and esp for ur quick responce ,God Bless u all
Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]Pimptastic | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]