|
In windows: use xampp. it is bundled with every of these XwindowsApacheMysqlPhpPerl so it is termed as xampp. for linux you have Lamp. One touch installer. and then go to xampp/htdocs folder . this is your document root. give a try and by this time i hope you would have got the answer because this post is two months old. I came here to ask a question but there aren't many posts anyway i will give a try.
Today's Beautiful Moments are
Tomorrow's Beautiful Memories
|
|
|
|
|
Hi All,
I am trying to insert the detail into one table with 2 fields. but I am failed to insert. Here I am getting the below error message.
Warning: odbc_execute() [function.odbc-execute]: SQL error: [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query., SQL state S1000 in SQLExecute in C:\Inetpub\wwwroot\PHPProgs\StoreData.php on line 9
Whoops
below is the code what i have written.
Please let me know what is the problem
Looking for your valuable reply.
|
|
|
|
|
Sounds like you may have a permissions issue. Can you insert/update any information to the database or just this table...check your security settings in the db for the user that your script is logging in as.
|
|
|
|
|
|
Hello !
I have very simple expression in if statement:
"d"==0
So in my code it looks like this:
if ("d"==0)
{
//do something
}
Of course, booth sides aren't always like that, they are variables, but I saw that I had bug somewhere and it turned out that error occurs always when on one side is string and on other zero ...
Can anyone explain to me why does this return true ?? I can't see why string would be equal to zero ...
Thanks
|
|
|
|
|
It returns false because you are comparing a string literal to a number. If your string was if("0"==0) it should work.
You may want to try to write the statement like this.
<?php
$test_array = array(1,"a",3,"b",5,"c",7,"d","e",0,"f","g","h","i","j","k");
$i = 0
foreach($test_array as $x)
{
if($x==0)
{
echo "found You at index ".$i."!<br>";
exit;
}
else
{
echo "still looking<br>";
}
}
$i++;
?>
This should help you...
|
|
|
|
|
I've tried that, and it returned:
still looking
found You at index 1!
So PHP thought that "a" was equal to 0 ... again, string is equal to zero, like in my first post ... what's going on ? is it maybe just error in my php installation ?? Right now, I'm very confused
BTW,
I've just tried that script on some other web server, result is the same ... is this kind of bug in PHP or what ?
Thanks
|
|
|
|
|
Sorry made a mistake in the code. This is what it should look like. See if you can spot the change. Understanding the difference between this code and the first one I posted will answer your question. You can then test it further by moving the 0 (zero) to a different location within the array.
<?php
$test_array = array(1,"a",3,"b",5,"c",7,"d","e",0,"f","g","h","i","j","k");
$i = 0;
foreach($test_array as $x)
{
if($x==0)
{
echo "found You at index ".$i."!<br>";
exit;
}
else
{
echo "still looking<br>";
}
$i++;
}
?>
|
|
|
|
|
Thank you for your help, but if you mean that error was this line:
$i++;
outside of foreach loop, I've already fixed it before trying the sample and it still don't work ...
http://x.xx77abs.com/example.php[^]
As you can see, it tells me that if found zero at index 1, and you can see source code that was executed (it is yours )
|
|
|
|
|
I made a change to the code and got it to give the expected results.
foreach($test_array as $x)
{
echo $x."<br>";
if($x==0 && is_numeric($x))
The echo of $x shows it is (without the is_numeric function) stopping on "a", not what I would expect. Running the code with the is_numeric gives the correct result of index 9. I also tested === with the same results as the is_numeric.
Without spending more time researching this I can only assume that php is parsing "a" as being equal to 0. I suspect this maybe due to something the parser is doing to allow the testing of a string and an integer.
OK, I just did a little research and found this in the PHP manual...
String conversion to numbers
When a string is evaluated in a numeric context, the resulting value and type are determined as follows.
If the string does not contain any of the characters '.', 'e', or 'E' and the numeric value fits into integer type limits (as defined by PHP_INT_MAX), the string will be evaluated as an integer . In all other cases it will be evaluated as a float .
The value is given by the initial portion of the string . If the string starts with valid numeric data, this will be the value used. Otherwise, the value will be 0 (zero). Valid numeric data is an optional sign, followed by one or more digits (optionally containing a decimal point), followed by an optional exponent. The exponent is an 'e' or 'E' followed by one or more digits.
For more information on this conversion, see the Unix manual page for strtod(3).
A quick google on strtod shows me this...
Return Value
On success, the function returns the converted floating point number as a double value.
If no valid conversion could be performed, a zero value (0.0) is returned.
If the correct value is out of the range of representable values, a positive or negative HUGE_VAL is returned, and the global variable errno is set to ERANGE.
If the correct value would cause underflow, zero is returned and errno is set to ERANGE.
This looks to be the issue...but this is just a guess.
|
|
|
|
|
and php does force a conversion of strings when they appear in a comparisons
If you compare a number with a string or the comparison involves numerical strings, then each string is converted to a number and the comparison performed numerically. These rules also apply to the switch statement. The type conversion does not take place when the comparison is === or !== as this involves comparing the type as well as the value.
source: http://www.php.net/manual/en/language.operators.comparison.php[^]
I also noted that on this page that speaks to comparisons they have the following sample code
<?php
var_dump(0 == "a");
var_dump("1" == "01");
var_dump("10" == "1e1");
var_dump(100 == "1e2");
switch ("a") {
case 0:
echo "0";
break;
case "a":
echo "a";
break;
}
?>
So even the manual supports the "a" == 0, but I can not find out exactly why it does this.
The questions I now have is does the function used in the conversion return a zero as a result or is this an error from the function which also returns a zero?
|
|
|
|
|
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 ****
|
|
|
|
|