php-windows Digest 31 Jul 2007 22:50:03 -0000 Issue 3299
Topics (messages 28289 through 28295):
Re: Arrays past to functions
28289 by: vikas batra
Re: n00b cannot start MySQL
28290 by: Abhisek Dutta
ORDER BY is not sorting
28291 by: Mark Abrams
28292 by: Dan Shirah
28293 by: tg-php.gryffyndevelopment.com
28294 by: tg-php.gryffyndevelopment.com
28295 by: Mark Abrams
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Wat is the problem with this code.
----- Original Message ----
From: Abhisek Dutta <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Sent: Tuesday, 31 July, 2007 3:07:06 PM
Subject: Re: [PHP-WIN] Arrays past to functions
Here's what i made:
<?
$taxrate=array('CA'=>5,'WA'=>7,'OR'=>8);
$states=array('CA','WA','OR');
function calctax($amount, $st)
{
global $taxrate;
global $states;
$tax=$amount*$taxrate[$st];
return $tax/100;
}
$amnt=200;
foreach($states as $st)
{
print "Tax in $st for amount $amnt is ".calctax($amnt, $st);
print "<br/>\n";
}
?>
Output:
Tax in CA for amount 200 is 10
Tax in WA for amount 200 is 14
Tax in OR for amount 200 is 16/
/
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Bollywood, fun, friendship, sports and more. You name it, we have it on
http://in.groups.yahoo.com
--- End Message ---
--- Begin Message ---
Thanks do much for all your help and support. Seems like my zonealarm
was blocking the port. after i uninstalled the program mysql is running
smoothly.
~regards and thanks
Abhisek
James Crow wrote:
try:
telnet localhost 3306
or
telnet 127.0.0.1 3306
"telnet 3306" tells windows to telnet to a host named 3306 on port 23.
Thanks,
James
On Sat, 2007-07-28 at 13:57 +0530, Abhisek Dutta wrote:
mysqld-nt.exe is running.
'netstat -an' gives:
<snip>
/
nowhere is 10061.
'telnet 3306' gives:
/Connecting To 3306...Could not open connection to the host, on port 23:
Connect
failed
/What to do?
Sorry to ask you all about mysql here.
Regards and thanks
abhisek
--- End Message ---
--- Begin Message ---
Sorry, this seams very trivial but I can not sort the result set for any
field. What am I doing wrong?
php & mySQL 5
<?php
...
$table_name ='users';
// Select records
$result = mysql_query("SELECT * FROM $table_name ORDER BY rowID DESC");
// Loop through the record set
while($row = mysql_fetch_array($result)) {
print 'rowID =' .$row['rowID']. '<br />'
}
?>
1
2
3
4
TIA
Mark
--- End Message ---
--- Begin Message ---
Well, it looks like you're trying to get your results in an array and run
the query all at the same time. Also, I believe you need to put the variable
in your SELECT statement inside of some single quotes.
Try something like this:
$query = "SELECT * FROM '$table_name' ORDER BY DESC";
$result = mysql_query($sql) or die(mysql_error());
Then you can take your $result variable and output the data, put it into a
loop, or select specific records.
Hope that helps.
On 7/31/07, Mark Abrams <[EMAIL PROTECTED]> wrote:
>
> Sorry, this seams very trivial but I can not sort the result set for any
> field. What am I doing wrong?
>
>
> php & mySQL 5
>
>
> <?php
>
> ...
>
> $table_name ='users';
>
> // Select records
> $result = mysql_query("SELECT * FROM $table_name ORDER BY rowID DESC");
>
>
> // Loop through the record set
> while($row = mysql_fetch_array($result)) {
> print 'rowID =' .$row['rowID']. '<br />'
> }
>
> ?>
>
> 1
> 2
> 3
> 4
>
>
> TIA
> Mark
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
I can't really see anything wrong with what you have there. It shouldn't
matter that your SQL is inside the query function, although I like to build the
query in a variable outside the query function, but either way it should work.
And you're obviously getting data and not an error, right?
What happens if you leave the "DESC" off? Does it come back 4, 3, 2, 1? or
still 1, 2, 3, 4?
You might try displaying more data from the result set to see if there's some
other issue.
And have you tested the SQL statement just using MySQL via command line,
phpMyAdmin, WinSQL, Navicat, or something like that?
-TG
= = = Original message = = =
Sorry, this seams very trivial but I can not sort the result set for any
field. What am I doing wrong?
php & mySQL 5
<?php
...
$table_name ='users';
// Select records
$result = mysql_query("SELECT * FROM $table_name ORDER BY rowID DESC");
// Loop through the record set
while($row = mysql_fetch_array($result))
print 'rowID =' .$row['rowID']. '<br />'
?>
1
2
3
4
TIA
Mark
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
--- End Message ---
--- Begin Message ---
Spaces would affect sorting if the spaces appeared in the actual rowID data.
If rowID is stored as text of some kind, then yeah, maybe he'd have an issue.
But I have a feeling you're talking about the code itself and whether to put
the quer into a variable or not (rebuting what I said).
Here's his code:
> $table_name ='users';
> $result = mysql_query("SELECT * FROM $table_name ORDER BY rowID DESC");
Code looks fine. $table_name gets substituted for it's value, 'users'. There
are no extra spaces in the variable data. Even if there was, that's fine. If
it were something like this, he'd have a problem:
> $result = mysql_query("SELECT * FROM ` $table_name` ORDER BY rowID DESC");
Then it would look for a table named <space>users. Which probably doesn't
exist.
Also.. that doesn't relate to the sorting issue since sorting is on 'rowID'
within that table, which isn't defined in a variable, but stated explicitly in
the query.
So not sure what you're saying about spaces messing things up.
-TG
= = = Original message = = =
Well, if you have blank spaces on the field's beginning it won't sort
correctly, it will put the blank spaces on the last results on that case.
On 7/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:
>
> I can't really see anything wrong with what you have there. It shouldn't
> matter that your SQL is inside the query function, although I like to build
> the query in a variable outside the query function, but either way it should
> work.
>
> And you're obviously getting data and not an error, right?
>
> What happens if you leave the "DESC" off? Does it come back 4, 3, 2,
> 1? or still 1, 2, 3, 4?
>
> You might try displaying more data from the result set to see if there's
> some other issue.
>
> And have you tested the SQL statement just using MySQL via command line,
> phpMyAdmin, WinSQL, Navicat, or something like that?
>
> -TG
>
> = = = Original message = = =
>
> Sorry, this seams very trivial but I can not sort the result set for any
> field. What am I doing wrong?
>
>
> php & mySQL 5
>
>
> <?php
>
> ...
>
> $table_name ='users';
>
> // Select records
> $result = mysql_query("SELECT * FROM $table_name ORDER BY rowID
> DESC");
>
>
> // Loop through the record set
> while($row = mysql_fetch_array($result))
> print 'rowID =' .$row['rowID']. '<br />'
>
>
> ?>
>
> 1
> 2
> 3
> 4
>
>
> TIA
> Mark
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> ___________________________________________________________
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Bruno Policarpo
[EMAIL PROTECTED]
MSN [EMAIL PROTECTED]
___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.
--- End Message ---
--- Begin Message ---
Is mysql_fetch_array the proper function to access sorted data? The
problem is consistent on my test server and my ISPs mySQL DB.
rowID is the primary key. Do I need to have an index attribute on a field I
want to sort?
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>I can't really see anything wrong with what you have there. It shouldn't
>matter that your SQL is inside the query function, although I like to build
>the query in a variable outside the query function, but either way it
>should work.
>
> And you're obviously getting data and not an error, right?
>
> What happens if you leave the "DESC" off? Does it come back 4, 3, 2, 1?
> or still 1, 2, 3, 4?
>
> You might try displaying more data from the result set to see if there's
> some other issue.
>
> And have you tested the SQL statement just using MySQL via command line,
> phpMyAdmin, WinSQL, Navicat, or something like that?
>
> -TG
>
> = = = Original message = = =
>
> Sorry, this seams very trivial but I can not sort the result set for any
> field. What am I doing wrong?
>
>
> php & mySQL 5
>
>
> <?php
>
> ...
>
> $table_name ='users';
>
> // Select records
> $result = mysql_query("SELECT * FROM $table_name ORDER BY rowID DESC");
>
>
> // Loop through the record set
> while($row = mysql_fetch_array($result))
> print 'rowID =' .$row['rowID']. '<br />'
>
>
> ?>
>
> 1
> 2
> 3
> 4
>
>
> TIA
> Mark
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> ___________________________________________________________
> Sent by ePrompter, the premier email notification software.
> Free download at http://www.ePrompter.com.
--- End Message ---