|
So that's it Thanks for explaining
|
|
|
|
|
|
Sometimes people learn more and better by example or a quick question, no need to discourage him.
|
|
|
|
|
Yeah, I know a little about that, and I know that operator === will work correctly as it will check for type and content of variable, but I just wanted one-line explanation
|
|
|
|
|
<Pretentious> Raid tha manyuhl. :E
<Pretentious> Aw raid eh own mah meaxbile. :E
|
|
|
|
|
This happens because strings, not just "a", are type cast to integer type when compared against an integer, and the integer that they are equivalent to is zero, which equals zero.
<?php<br />
<br />
$typecastme = array(<br />
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'<br />
);<br />
<br />
echo '<pre>';<br />
foreach ($typecastme as $int => $str) {<br />
echo 'if('.$str.'=='.$int.') is: '.($str==$int?'TRUE':'FALSE')."\n";<br />
echo ''.$str.' as boolean is: '.((bool)$str?'TRUE':'FALSE')."\n";<br />
echo ''.$str.' as integer is: '.(integer)$str."\n";<br />
echo 'var_dump('.$str.'=='.$int.') is: ';<br />
var_dump($str==$int);<br />
echo 'var_dump((int)'.$str.'==0) is: ';<br />
var_dump((int)$str==0);<br />
echo "\n";<br />
}<br />
echo '</pre>';
|
|
|
|
|
Hi,
I am sharing a PHP tips with you all. Below is the brief about the tips.
Instead of designing and writing the data in a Excel file, it is much easier to have a template with all the designs embedded. We have to just read the template file and write our data in the particular cells. But if we are going to have, say, 'n' number of sheets, then the template file also should have the same number of sheets whose memory will also be high and the time it takes to read it will also be high.
Hope you find this PHP tips useful and of assistance. For more detail, please visit this link http://www.mindfiresolutions.com/Changing-SharePoint-site-locale-programmatically-834.php[^]
Thanks,
Bijayani
|
|
|
|
|
This belongs in Tips/Tricks[^]
Kristian Sixhoej
I have noticed even people who claim everything is predestined,
and that we can do nothing to change it, look before they cross the road. - Stephen Hawking
|
|
|
|
|
This is the third time you have done this and you seem not to have taken any notice of the replies you received. If you have a great idea then either write an article and submit it for publication, or post it to the Tips and Tricks list. Please do not post this sort of entry to the forums which are specifically for technical questions.
It's time for a new signature.
|
|
|
|
|
I am new to Linux. CAn anyone tell me which is the best and fastest way to get acquaint with it??
|
|
|
|
|
pc.bharti wrote: I am new to Linux. CAn anyone tell me which is the best and fastest way to get acquaint with it??
Common sense would suggest by looking at the Linux home page[^]!
It's time for a new signature.
|
|
|
|
|
I think the first to do install a linux OS
|
|
|
|
|
Google is the best way for learning everything.
but if you want to learn linux programming, the best book is "Beginning Linux Programming, 4th Edition"
|
|
|
|
|
Having trouble with this little DOM PHP task. When i parse it from unix with the command -> php DOMSearch.php "Brookside"
it prints out
Channel 5
Start : 2001-07-0521:55:00
However, it should print out all channels and start times from the "Brookside" series like below:
Channel 4
Start : 2001-07-05T20:00:00
Start : 2001-07-05T20:30:00
Channel 5
Start : 2001-07-0521:55:00
my script is only going through the document once and only returning one result
can anyone help me how to keep looping through and print channel and start time when series matches what the user has entered.
**** PHP CODE ****
<?php<br />
$objDOM = new DOMDocument(); <br />
$objDOM->load('TVGuide.xml'); <br />
$series = $argv[1];<br />
$channel = $objDOM->getElementsByTagName("Channel"); <br />
$chan = $channel->item(0)->nodeValue; <br />
foreach( $channel as $value )<br />
{<br />
$names = $value->getElementsByTagName("Name");<br />
$name = $names->item(0)->nodeValue;<br />
$program = $objDOM->getElementsByTagName("Program");<br />
foreach( $program as $prog )<br />
{<br />
$starts = $prog->getElementsByTagName("Start");<br />
$start = $starts->item(0)->nodeValue;<br />
$serie = $prog->getElementsByTagName("Series");<br />
$ser = $serie->item(0)->nodeValue;<br />
}<br />
}<br />
if($series == $ser)<br />
{<br />
echo "$name\n";<br />
echo "Start : $start\n";<br />
} <br />
<br />
?>
**** XML SOURCE CODE ****
|
|
|
|
|
The section that does the output is outside the loop - so it's only printing the last entry.
Move the if($series == $ser) { ... } block inside the inner loop and it will improve things. You'll need to add a test for the first occurrence of the channel to prevent it being output for each programme too.
|
|
|
|
|
I am building a web membership site. when a new member signs up he is able the choose a username that will be used for tracking purposes, such as mike or chuck. The user name is the primary key in a MySql database. If there is already a 'chuck' in the system and a new user requests 'chuck' as a username the insert will fail, and that is OK. The php script catches the failure, the problem is that it puts an ugly message on the screen and break the process. I could change the message but that does not solve the problem.
What I want is a nice little dialog box that says that another name or name not available and redisplay the original signup screen?
This is my first php program (I've been writing code for more than 30 years). So I need to know how to return to the base application so the user and enter a different username.
Here is a code snippet of the error location where I would like to make the appropiate change:
if(!mysql_query('INSERT INTO `' . CC_FB_DB_TABLE . '` SET ' .
$query . "`created_at` = NOW()", $link))
{
printMessage('Unable to Insert Into Database Table.',
"We're sorry but we were unable to insert the form results " .
'into your database table. Please be sure that you have ' .
'the proper permissions to insert data into the ' .
CC_FB_DB_TABLE . ' table. If you are still experiencing ' .
'trouble, please contact your server administrator.');
}
*****************
Thanks for your assistance in advance...
Chuck
|
|
|
|
|
You can use a try ... catch to handle the error elegantly or use @ with the function name to suppress the error message, but in my opinion, allowing a known error to happen in the first place is a poor design.
I would do a simple SELECT query before to see if the name exists, then act accordingly.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
modified on Wednesday, May 19, 2010 11:32 AM
|
|
|
|
|
Don't like the catch an error either.
My first choice is to do as you suggested. I guess what I should be asking is does php work like the code behind asp.net where once the enter key is pressed it runs the code behind, in this case the php.
If so how do I get a little message box on the screen indicating that the username has alreadu been taken and to try another one?
|
|
|
|
|
I'm not an expert in asp.net, but PHP is just server side, so if you need to get the info back to the client browser, you'll have to do something else, like use AJAX.
I have a user registration web page embedded in a PHP script (or PHP in a web page -- depends on your viewpoint) with a parameter indicating an error message. The first time you call the web page, the error message is blank so nothing is displayed.
If the registration succeeds, the PHP script redirects to a login or a secure page. If it fails it reloads the registration page again with a message that the user name is already taken (or database in unavailable, or password was blank, etc.).
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Walt this is great..
I really appreciate your assistance.
I will look to implement this later today..
Could you answer a resource question..?
I noticed a site called PHPLabs, they claim to have lots of goodies and great support for PH issues.
Do you know anything about them?
Thanks..
Chuck..
|
|
|
|
|
I'm glad my suggestions may have helped. To me, the registration and login is just the first hurdle -- after that you probably need to maintain session info, and doing that securely offers other challenges!
I've never heard of PHPLabs before. I see they want to charge to be a member, so I don't think I'm interested. So far I've always found answers to my PHP questions using Bing (or Google). If you decide to delve into PHPLabs, I'd be happy to hear what you think.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Thanks Walt..I'll probably save my money for now...
|
|
|
|
|
|
Thanks Richard..
I'll look into these sites..
Cheers..
Chuck..
|
|
|
|
|
Hi Experts,
Please let me know if any method is there to convert .json file to .po/.pot file in python script.. I have used Gettext library to parse po files and convert it to .json. But can't found any one to parse po files...
Regards,
Spk
|
|
|
|