Re: [PHP] whats wrong

2012-04-01 Thread tamouse mailing lists
On Sat, Mar 31, 2012 at 6:36 AM, Maciek Sokolewicz
maciek.sokolew...@gmail.com wrote:
 On 31-03-2012 10:29, tamouse mailing lists wrote:

 On Sat, Mar 31, 2012 at 1:45 AM, saeed ahmedmycomputerbo...@gmail.com
  wrote:

 i have made a php script with a tutorial helpi dont know where is a
 error.please have a look


 Before you actually run code in a browser, check your syntax with php
 -l (for lint, the old command to check C syntax on unixy systems) on
 a command line. This will improve your life immeasurably since you
 won't have to chase down where the server logs errors just to see if
 your code was syntactically correct.

 miishka:Sites tamara$ php -l test.saeed.php
 PHP Parse error:  syntax error, unexpected T_STRING in test.saeed.php on
 line 6
 Errors parsing test.saeed.php
 miishka:Sites tamara$

 Which points out the syntax error on line 6 where you have:

   $result=mysql_query(select(SELECT*FROM COLLEAGUE);

 Which as an improperly formed select sql, and an unclosed string (thus
 sucking up part of your php code and html document. To fix this, it
 should be:

   $result=mysql_query($db, SELECT * FROM COLLEAGUE);


 Wrong, it should be the other way around. First the query, and then an
 OPTIONAL link-identifier (which I assume $db to be in this case).


 i.e., the sql statement is in a single string. Also, spacing around
 the column list * may or may not be necessary, but it's a lot easier
 to read if it's there. Also, you need to tell the query procedure what
 data base you're using the $db variable (see below for this).

 Ok, that fixed, run php -l on the file again, and we get:

    PHP Parse error:  syntax error, unexpected '' in test.saeed.php on
 line 31
    Errors parsing test.saeed.php

 Looking at line 31:

    echo td . $row['firstName'] ./td;

 it looks fine, you might be wondering why it's complaining about that
 line. The key is to look up from there for possible syntax problems,
 and on line 30, there is a problem in that you didn't close the last
 string:

    echotd.$row['id'] ./td;

 should be:

    echotd.$row['id'] ./td;


 Ok, fix that, run php -l again:

    PHP Parse error:  syntax error, unexpected '[', expecting ',' or
 ';' in test.saeed.php on line 34
    Errors parsing test.saeed.php

 So, look at line 34 now:

    echo td . Srow['email'] ./td;

 The problem is that you typoed the dollar sign in front of row. It should
 be:

    echo td . $row['email'] ./td;

 Also, on this line, although php -l won't catch it, is an html error.
 The last /td is not closed, so:

    echo td . $row['email'] ./td;

 Run php -l again, and this time, voila:

    No syntax errors detected in test.saeed.php

 That solves your syntax errors. Now you can test it from a server.

 Before you do that though, a few other points:

 When developing code, it's a really good idea to turn on run time
 error checking so you can see things in the browser when a problem
 crops up:

   ?php
   error_reporting(-1); // turns on EVERYTHING
   ini_set('display_errors',true);
   ini_set('display_startup_errors',true);

   // follow with your code...


 This won't help if your code doesn't parse correctly, but that's what
 the php -l is for above, but it will reveal run-time processing errors
 in your browser. And you have several.

 As another responder said, checking the return values of functions is
 important. Sometimes tutorials omit this for the sake of brevity, but
 it is something that still should be done.

 Line 3:

    mysql_connect(localhost,root,  );

 is incorrect on at least two levels. First, you haven't saved the data
 base resource that is returned from mysql_connect, and second, you
 haven't checked that the call was successful. Third, possibly is that
 you have specified the root mysql password a string of one space. This
 is unlikely to be the password.

 It should be rewritten as:

    $db = mysql_connect(localhost, root, ) or die(Could not
 connect to mysql server on local host:  . mysql_error() . PHP_EOL);

 The next line:

     mysql_select_db(addressbook);

 is also incorrect as it does not specify the data base resource which
 you omitted in the previous call, and you aren't (again) checking the
 result to see if it works.

 It should be rewritten as:

    mysql_select_db($db, addressbook) or die (Could not connect to
 data base 'addressbook'. Error:  . mysql_error($db) . PHP_EOL);

 Back to that line 6, after you've repaired it, you *again* need to
 check that the query actually worked. After that query, include the
 following line:

    if (FALSE === $result) die (Query failed. Error:  .
 mysql_error($db) . PHP_EOL);

 Note that if the table is empty, that is not an error; your result set
 will simply be empty. Returning FALSE indicates that there was an
 actual error in the query. I find it better to put the sql statement
 into a string, and then use the string variable in the actual query
 function. This lets you also print out the query as it was sent to
 mysql:

    $sql = 

Re: [PHP] whats wrong

2012-03-31 Thread Tommy Pham
On Fri, Mar 30, 2012 at 11:45 PM, saeed ahmed mycomputerbo...@gmail.com wrote:
 i have made a php script with a tutorial helpi dont know where is a
 error.please have a look


Your code below assumes that everything is perfect in your world.  IE:
 no network connectivity issue, all firewall related are properly
configured, the user account actually exists and have the right
permissions, the database exists and so are the table(s), etc  I
suggest you revisit the official PHP manual and read about each
function you're using.


 ?php
 //connect and select a database
 mysql_connect(localhost,root,  );

for starters,

http://php.net/function.mysql-connect

Noticed the result returned.  You didn't bother to check whether if
it's successful or not.  If not why not?  Since the DB is on the same
box, is the firewall, if any, configured properly?  If there's no
firewall or if it's configured properly, is the account valid and have
the right permissions?  Is the MySQL server running on the default
port 3306?

If you don't know how to configure each of the above mentioned, allow
me to introduce you a new friend, Google ;)  Both of those topics are
beyond the scope of this list.

HTH,
Tommy

 mysql_select_db(addressbook);
 //Run a query
 $result=mysql_query(select(SELECT*FROM COLLEAGUE);
 ?
 !DOCTYPE html PUBLIC-//w3c//DTD XHTML 1.0 Transitional//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml;
 head
 titleAddress Book/title
 meta http-equiv=content-type content=text/html;charset=utf-8
 /head
 body
 h1Address Bookh1
 table Border=1 cellpadding=2cellspacing=3
 summary=table holda colleague contacts information
 tr
 th ID/th
 thFirst Name/th
 thLast Name/th
 thTelephone/th
 thEmail Address/th
 /tr
 ?php
 //LOOP through all table rows
 while ($row=mysql_fetch_array($result)) {
 echotr;
 echotd.$row['id'] . /td;
 echo td . $row['firstName'] . /td;
 echo td . $row['lastName'] . /td;
 echo td . $row['telephone'] . /td;
 echo td . Srow['email'] . /td;
 echo/tr;
 }
 //free result memory and close database connection
 mysql_free_result($result);
 mysql_close();
 ?
 /table
 /body
 /html
 thanks

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] whats wrong

2012-03-31 Thread Duken Marga
Please check this line:
 $result=mysql_query(select(SELECT*FROM COLLEAGUE);

I think it should be:
  $result=mysql_query(SELECT * FROM COLLEAGUE);

On Sat, Mar 31, 2012 at 1:45 PM, saeed ahmed mycomputerbo...@gmail.comwrote:

 i have made a php script with a tutorial helpi dont know where is a
 error.please have a look


 ?php
 //connect and select a database
 mysql_connect(localhost,root,  );
 mysql_select_db(addressbook);
 //Run a query
 $result=mysql_query(select(SELECT*FROM COLLEAGUE);
 ?
 !DOCTYPE html PUBLIC-//w3c//DTD XHTML 1.0 Transitional//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml;
 head
 titleAddress Book/title
 meta http-equiv=content-type content=text/html;charset=utf-8
 /head
 body
 h1Address Bookh1
 table Border=1 cellpadding=2cellspacing=3
 summary=table holda colleague contacts information
 tr
 th ID/th
 thFirst Name/th
 thLast Name/th
 thTelephone/th
 thEmail Address/th
 /tr
 ?php
 //LOOP through all table rows
 while ($row=mysql_fetch_array($result)) {
 echotr;
 echotd.$row['id'] . /td;
 echo td . $row['firstName'] . /td;
 echo td . $row['lastName'] . /td;
 echo td . $row['telephone'] . /td;
 echo td . Srow['email'] . /td;
 echo/tr;
 }
 //free result memory and close database connection
 mysql_free_result($result);
 mysql_close();
 ?
 /table
 /body
 /html
 thanks




-- 
Duken Marga


Re: [PHP] whats wrong

2012-03-31 Thread tamouse mailing lists
On Sat, Mar 31, 2012 at 1:45 AM, saeed ahmed mycomputerbo...@gmail.com wrote:
 i have made a php script with a tutorial helpi dont know where is a
 error.please have a look

Before you actually run code in a browser, check your syntax with php
-l (for lint, the old command to check C syntax on unixy systems) on
a command line. This will improve your life immeasurably since you
won't have to chase down where the server logs errors just to see if
your code was syntactically correct.

miishka:Sites tamara$ php -l test.saeed.php
PHP Parse error:  syntax error, unexpected T_STRING in test.saeed.php on line 6
Errors parsing test.saeed.php
miishka:Sites tamara$

Which points out the syntax error on line 6 where you have:

  $result=mysql_query(select(SELECT*FROM COLLEAGUE);

Which as an improperly formed select sql, and an unclosed string (thus
sucking up part of your php code and html document. To fix this, it
should be:

  $result=mysql_query($db, SELECT * FROM COLLEAGUE);

i.e., the sql statement is in a single string. Also, spacing around
the column list * may or may not be necessary, but it's a lot easier
to read if it's there. Also, you need to tell the query procedure what
data base you're using the $db variable (see below for this).

Ok, that fixed, run php -l on the file again, and we get:

   PHP Parse error:  syntax error, unexpected '' in test.saeed.php on line 31
   Errors parsing test.saeed.php

Looking at line 31:

   echo td . $row['firstName'] . /td;

it looks fine, you might be wondering why it's complaining about that
line. The key is to look up from there for possible syntax problems,
and on line 30, there is a problem in that you didn't close the last
string:

   echotd.$row['id'] . /td;

should be:

   echotd.$row['id'] . /td;


Ok, fix that, run php -l again:

   PHP Parse error:  syntax error, unexpected '[', expecting ',' or
';' in test.saeed.php on line 34
   Errors parsing test.saeed.php

So, look at line 34 now:

   echo td . Srow['email'] . /td;

The problem is that you typoed the dollar sign in front of row. It should be:

   echo td . $row['email'] . /td;

Also, on this line, although php -l won't catch it, is an html error.
The last /td is not closed, so:

   echo td . $row['email'] . /td;

Run php -l again, and this time, voila:

   No syntax errors detected in test.saeed.php

That solves your syntax errors. Now you can test it from a server.

Before you do that though, a few other points:

When developing code, it's a really good idea to turn on run time
error checking so you can see things in the browser when a problem
crops up:

  ?php
  error_reporting(-1); // turns on EVERYTHING
  ini_set('display_errors',true);
  ini_set('display_startup_errors',true);

  // follow with your code...


This won't help if your code doesn't parse correctly, but that's what
the php -l is for above, but it will reveal run-time processing errors
in your browser. And you have several.

As another responder said, checking the return values of functions is
important. Sometimes tutorials omit this for the sake of brevity, but
it is something that still should be done.

Line 3:

   mysql_connect(localhost,root,  );

is incorrect on at least two levels. First, you haven't saved the data
base resource that is returned from mysql_connect, and second, you
haven't checked that the call was successful. Third, possibly is that
you have specified the root mysql password a string of one space. This
is unlikely to be the password.

It should be rewritten as:

   $db = mysql_connect(localhost, root, ) or die(Could not
connect to mysql server on local host:  . mysql_error() . PHP_EOL);

The next line:

mysql_select_db(addressbook);

is also incorrect as it does not specify the data base resource which
you omitted in the previous call, and you aren't (again) checking the
result to see if it works.

It should be rewritten as:

   mysql_select_db($db, addressbook) or die (Could not connect to
data base 'addressbook'. Error:  . mysql_error($db) . PHP_EOL);

Back to that line 6, after you've repaired it, you *again* need to
check that the query actually worked. After that query, include the
following line:

   if (FALSE === $result) die (Query failed. Error:  .
mysql_error($db) . PHP_EOL);

Note that if the table is empty, that is not an error; your result set
will simply be empty. Returning FALSE indicates that there was an
actual error in the query. I find it better to put the sql statement
into a string, and then use the string variable in the actual query
function. This lets you also print out the query as it was sent to
mysql:

   $sql = select * from colleague;
   $result = mysql_query($db, $sql);
   if (FALSE === $result) die (Query failed. \$sql=$sql. Error:  .
mysql_error($db) . PHP_EOL);

A little further on, there is a problem in the html meta statement:
there is no closer on that line:

   meta http-equiv=content-type content=text/html;charset=utf-8

It needs to be closed with / since you're using 

Re: [PHP] whats wrong

2012-03-31 Thread Maciek Sokolewicz

On 31-03-2012 10:29, tamouse mailing lists wrote:

On Sat, Mar 31, 2012 at 1:45 AM, saeed ahmedmycomputerbo...@gmail.com  wrote:

i have made a php script with a tutorial helpi dont know where is a
error.please have a look


Before you actually run code in a browser, check your syntax with php
-l (for lint, the old command to check C syntax on unixy systems) on
a command line. This will improve your life immeasurably since you
won't have to chase down where the server logs errors just to see if
your code was syntactically correct.

miishka:Sites tamara$ php -l test.saeed.php
PHP Parse error:  syntax error, unexpected T_STRING in test.saeed.php on line 6
Errors parsing test.saeed.php
miishka:Sites tamara$

Which points out the syntax error on line 6 where you have:

   $result=mysql_query(select(SELECT*FROM COLLEAGUE);

Which as an improperly formed select sql, and an unclosed string (thus
sucking up part of your php code and html document. To fix this, it
should be:

   $result=mysql_query($db, SELECT * FROM COLLEAGUE);


Wrong, it should be the other way around. First the query, and then an 
OPTIONAL link-identifier (which I assume $db to be in this case).


i.e., the sql statement is in a single string. Also, spacing around
the column list * may or may not be necessary, but it's a lot easier
to read if it's there. Also, you need to tell the query procedure what
data base you're using the $db variable (see below for this).

Ok, that fixed, run php -l on the file again, and we get:

PHP Parse error:  syntax error, unexpected '' in test.saeed.php on line 31
Errors parsing test.saeed.php

Looking at line 31:

echo td . $row['firstName'] ./td;

it looks fine, you might be wondering why it's complaining about that
line. The key is to look up from there for possible syntax problems,
and on line 30, there is a problem in that you didn't close the last
string:

echotd.$row['id'] ./td;

should be:

echotd.$row['id'] ./td;


Ok, fix that, run php -l again:

PHP Parse error:  syntax error, unexpected '[', expecting ',' or
';' in test.saeed.php on line 34
Errors parsing test.saeed.php

So, look at line 34 now:

echo td . Srow['email'] ./td;

The problem is that you typoed the dollar sign in front of row. It should be:

echo td . $row['email'] ./td;

Also, on this line, although php -l won't catch it, is an html error.
The last /td is not closed, so:

echo td . $row['email'] ./td;

Run php -l again, and this time, voila:

No syntax errors detected in test.saeed.php

That solves your syntax errors. Now you can test it from a server.

Before you do that though, a few other points:

When developing code, it's a really good idea to turn on run time
error checking so you can see things in the browser when a problem
crops up:

   ?php
   error_reporting(-1); // turns on EVERYTHING
   ini_set('display_errors',true);
   ini_set('display_startup_errors',true);

   // follow with your code...


This won't help if your code doesn't parse correctly, but that's what
the php -l is for above, but it will reveal run-time processing errors
in your browser. And you have several.

As another responder said, checking the return values of functions is
important. Sometimes tutorials omit this for the sake of brevity, but
it is something that still should be done.

Line 3:

mysql_connect(localhost,root,  );

is incorrect on at least two levels. First, you haven't saved the data
base resource that is returned from mysql_connect, and second, you
haven't checked that the call was successful. Third, possibly is that
you have specified the root mysql password a string of one space. This
is unlikely to be the password.

It should be rewritten as:

$db = mysql_connect(localhost, root, ) or die(Could not
connect to mysql server on local host:  . mysql_error() . PHP_EOL);

The next line:

 mysql_select_db(addressbook);

is also incorrect as it does not specify the data base resource which
you omitted in the previous call, and you aren't (again) checking the
result to see if it works.

It should be rewritten as:

mysql_select_db($db, addressbook) or die (Could not connect to
data base 'addressbook'. Error:  . mysql_error($db) . PHP_EOL);

Back to that line 6, after you've repaired it, you *again* need to
check that the query actually worked. After that query, include the
following line:

if (FALSE === $result) die (Query failed. Error:  .
mysql_error($db) . PHP_EOL);

Note that if the table is empty, that is not an error; your result set
will simply be empty. Returning FALSE indicates that there was an
actual error in the query. I find it better to put the sql statement
into a string, and then use the string variable in the actual query
function. This lets you also print out the query as it was sent to
mysql:

$sql = select * from colleague;
$result = mysql_query($db, $sql);


Again, query first, linkidentifier after that. This way you'll always 
get an error.



if 

Re: [PHP] whats wrong in this program.

2005-09-14 Thread babu
Hi,
 
I tried to use the final array values in a insert statement, but the values are 
not inserted.
the code is
 
foreach ($final as $subnum){ 
 $res = $db-query(INSERT INTO 
substrate_protocoll(substrate_type,substrate_num,operator,location,solvent,ultrasonic,duration,cdate,ctime,comment)
 
  
VALUES('$substrate_type1',$subnum,'$operator','$location','$solvent',$uv,$duration,'$cdate','$sctime','$comment'));
if(!$res){
 echo insert failed;
 }   
}
the values of array ($subnum)are not inserted , can you tell me where the 
problem is.

Jordan Miller [EMAIL PROTECTED] wrote:
I think I finally understand what you are trying to do. I don't see 
any reason why you need to use the token functions, and I would 
recommend using array functions instead (also, it is exceedingly easy 
to sort the elements of an array... see the end).

I believe this will do what you are trying to do:
//Tokenizer for Babu
$str = '10,12,14-18';
$commas = explode(',', $str); // $commas will be an array of three 
items in this case

// Final Values will go into the $final array
$final = array();
foreach ($commas as $value) {
// If one of the $commas elements contains a dash, we need to 
get the range between them!
if (strstr($value, '-')) {
// Explode based on the dash. This code assumes there will 
only be a single dash
$rangeValues = explode('-', $value);
foreach (range($rangeValues[0], $rangeValues[1]) as $number) {
$final[] = $number;
}
} else {
// If $value does not contain a dash, add it directly to the 
$final array
$final[] = $value;
}
}
echo All your values in the range $str are .implode(' ', $final);
// Prints All your values in the range 10,12,14-18 are 10 12 14 15 
16 17 18


In your last email, you had some of the values given out of order:
1. 20,21-24
2. 21-24,20
3. 10,20,21-24,25,26,30

To make sure the $final values are always ascending, just do this at 
the end:
sort($final);

Done!!

Jordan




On Sep 13, 2005, at 7:16 PM, babu wrote:

 $str=10,12,14-18;

 $tok = strtok($str, ',');
 while ($tok !== false) {
 $toks[] = $tok;
 $tok = strtok(',');
 }

 foreach ($toks as $token){
 if (strpos($token,'-')){
 stringtokenize($token);
 }else{
 $finaltokens[]= $token;
 }
 }

 function stringtokenize($nstr){
 $ntok1= strtok($nstr,'-');
 $ntok2=strtok('-');
 for($i=$ntok1;$i=$ntok2;$i++){
 $finaltokens[]= $i;
 }
 }

 foreach ($finaltokens as $ftoken){
 echo $ftoken;
 echo 
;
 }

 the ouput prints only 10,12 but not 14,15,16,17,18. where is the 
 problem.



 -
 To help you stay safe and secure online, we've developed the all 
 new Yahoo! Security Centre.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-
How much free photo storage do you get? Store your holiday snaps for FREE with 
Yahoo! Photos. Get Yahoo! Photos

Re: [PHP] whats wrong in this program.

2005-09-14 Thread Mark Rees

 I tried to use the final array values in a insert statement, but the
values are not inserted.
 the code is

 foreach ($final as $subnum){
  $res = $db-query(INSERT INTO
substrate_protocoll(substrate_type,substrate_num,operator,location,solvent,u
ltrasonic,duration,cdate,ctime,comment)

VALUES('$substrate_type1',$subnum,'$operator','$location','$solvent',$uv,$du
ration,'$cdate','$sctime','$comment'));
 if(!$res){
  echo insert failed;
  }
 }
 the values of array ($subnum)are not inserted , can you tell me where the
problem is.

the problem is probably in this line:

echo (INSERT INTO
substrate_protocoll(substrate_type,substrate_num,operator,location,solvent,u
ltrasonic,duration,cdate,ctime,comment)

VALUES('$substrate_type1',$subnum,'$operator','$location','$solvent',$uv,$du
ration,'$cdate','$sctime','$comment'));

and the problem is that you haven't done this to see what is wrong with the
SQL.

The next problem is that this line is also missing:

echo mysql_error();





 Jordan Miller [EMAIL PROTECTED] wrote:
 I think I finally understand what you are trying to do. I don't see
 any reason why you need to use the token functions, and I would
 recommend using array functions instead (also, it is exceedingly easy
 to sort the elements of an array... see the end).

 I believe this will do what you are trying to do:
 //Tokenizer for Babu
 $str = '10,12,14-18';
 $commas = explode(',', $str); // $commas will be an array of three
 items in this case

 // Final Values will go into the $final array
 $final = array();
 foreach ($commas as $value) {
 // If one of the $commas elements contains a dash, we need to
 get the range between them!
 if (strstr($value, '-')) {
 // Explode based on the dash. This code assumes there will
 only be a single dash
 $rangeValues = explode('-', $value);
 foreach (range($rangeValues[0], $rangeValues[1]) as $number) {
 $final[] = $number;
 }
 } else {
 // If $value does not contain a dash, add it directly to the
 $final array
 $final[] = $value;
 }
 }
 echo All your values in the range $str are .implode(' ', $final);
 // Prints All your values in the range 10,12,14-18 are 10 12 14 15
 16 17 18


 In your last email, you had some of the values given out of order:
 1. 20,21-24
 2. 21-24,20
 3. 10,20,21-24,25,26,30

 To make sure the $final values are always ascending, just do this at
 the end:
 sort($final);

 Done!!

 Jordan




 On Sep 13, 2005, at 7:16 PM, babu wrote:

  $str=10,12,14-18;
 
  $tok = strtok($str, ',');
  while ($tok !== false) {
  $toks[] = $tok;
  $tok = strtok(',');
  }
 
  foreach ($toks as $token){
  if (strpos($token,'-')){
  stringtokenize($token);
  }else{
  $finaltokens[]= $token;
  }
  }
 
  function stringtokenize($nstr){
  $ntok1= strtok($nstr,'-');
  $ntok2=strtok('-');
  for($i=$ntok1;$i=$ntok2;$i++){
  $finaltokens[]= $i;
  }
  }
 
  foreach ($finaltokens as $ftoken){
  echo $ftoken;
  echo 
 ;
  }
 
  the ouput prints only 10,12 but not 14,15,16,17,18. where is the
  problem.
 
 
 
  -
  To help you stay safe and secure online, we've developed the all
  new Yahoo! Security Centre.

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



 -
 How much free photo storage do you get? Store your holiday snaps for FREE
with Yahoo! Photos. Get Yahoo! Photos

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] whats wrong in this program.

2005-09-14 Thread Jordan Miller
you need single quotes around $subnum in the sql statement. don't  
know why you seem to be arbitrarily leaving them off (put them around  
$uv and $duration, too!).


also, you should never insert stuff directly from a user into a  
database. first escape every variable with:

http://www.php.net/mysql_real_escape_string

Jordan



On Sep 14, 2005, at 6:36 AM, babu wrote:


Hi,

I tried to use the final array values in a insert statement, but  
the values are not inserted.

the code is

foreach ($final as $subnum){
 $res = $db-query(INSERT INTO substrate_protocoll 
(substrate_type,substrate_num,operator,location,solvent,ultrasonic,dur 
ation,cdate,ctime,comment)
  VALUES('$substrate_type1', 
$subnum,'$operator','$location','$solvent',$uv, 
$duration,'$cdate','$sctime','$comment'));

if(!$res){
 echo insert failed;
 }
}
the values of array ($subnum)are not inserted , can you tell me  
where the problem is.


Jordan Miller [EMAIL PROTECTED] wrote:
I think I finally understand what you are trying to do. I don't see
any reason why you need to use the token functions, and I would
recommend using array functions instead (also, it is exceedingly easy
to sort the elements of an array... see the end).

I believe this will do what you are trying to do:
//Tokenizer for Babu
$str = '10,12,14-18';
$commas = explode(',', $str); // $commas will be an array of three
items in this case

// Final Values will go into the $final array
$final = array();
foreach ($commas as $value) {
// If one of the $commas elements contains a dash, we need to
get the range between them!
if (strstr($value, '-')) {
// Explode based on the dash. This code assumes there will
only be a single dash
$rangeValues = explode('-', $value);
foreach (range($rangeValues[0], $rangeValues[1]) as $number) {
$final[] = $number;
}
} else {
// If $value does not contain a dash, add it directly to the
$final array
$final[] = $value;
}
}
echo All your values in the range $str are .implode(' ', $final);
// Prints All your values in the range 10,12,14-18 are 10 12 14 15
16 17 18


In your last email, you had some of the values given out of order:
1. 20,21-24
2. 21-24,20
3. 10,20,21-24,25,26,30

To make sure the $final values are always ascending, just do this at
the end:
sort($final);

Done!!

Jordan




On Sep 13, 2005, at 7:16 PM, babu wrote:



$str=10,12,14-18;

$tok = strtok($str, ',');
while ($tok !== false) {
$toks[] = $tok;
$tok = strtok(',');
}

foreach ($toks as $token){
if (strpos($token,'-')){
stringtokenize($token);
}else{
$finaltokens[]= $token;
}
}

function stringtokenize($nstr){
$ntok1= strtok($nstr,'-');
$ntok2=strtok('-');
for($i=$ntok1;$i=$ntok2;$i++){
$finaltokens[]= $i;
}
}

foreach ($finaltokens as $ftoken){
echo $ftoken;
echo 


;


}

the ouput prints only 10,12 but not 14,15,16,17,18. where is the
problem.



-
To help you stay safe and secure online, we've developed the all
new Yahoo! Security Centre.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



-
How much free photo storage do you get? Store your holiday snaps  
for FREE with Yahoo! Photos. Get Yahoo! Photos


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] whats wrong in this program.

2005-09-14 Thread John Nichel

Jordan Miller wrote:
you need single quotes around $subnum in the sql statement. don't  know 
why you seem to be arbitrarily leaving them off (put them around  $uv 
and $duration, too!).

snip

It's not needed if those fields are integers.

*damnit, that's twice today I've replied to the poster and not the list.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] whats wrong in this program.

2005-09-14 Thread Jordan Miller

heh, i did it too.



John,

oh, good to know, thanks. $final should be composed of strings, not  
integers, so i guess that is his problem. i just read that it is  
best to quote every variable, now I know why... so you can change  
implementations later and not have to worry about types (and php's  
autotyping is so great anyway).


Jordan





On Sep 14, 2005, at 10:54 AM, John Nichel wrote:


Jordan Miller wrote:

you need single quotes around $subnum in the sql statement. don't   
know why you seem to be arbitrarily leaving them off (put them  
around  $uv and $duration, too!).



snip

It's not needed if those fields are integers.

*damnit, that's twice today I've replied to the poster and not the  
list.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] whats wrong in this program.

2005-09-13 Thread Jordan Miller
I think I finally understand what you are trying to do. I don't see  
any reason why you need to use the token functions, and I would  
recommend using array functions instead (also, it is exceedingly easy  
to sort the elements of an array... see the end).


I believe this will do what you are trying to do:
//Tokenizer for Babu
$str = '10,12,14-18';
$commas = explode(',', $str); // $commas will be an array of three  
items in this case


// Final Values will go into the $final array
$final = array();
foreach ($commas as $value) {
// If one of the $commas elements contains a dash, we need to  
get the range between them!

if (strstr($value, '-')) {
// Explode based on the dash. This code assumes there will  
only be a single dash

$rangeValues = explode('-', $value);
foreach (range($rangeValues[0], $rangeValues[1]) as $number) {
$final[] = $number;
}
} else {
// If $value does not contain a dash, add it directly to the  
$final array

$final[] = $value;
}
}
echo All your values in the range $str are .implode(' ', $final);
// Prints All your values in the range 10,12,14-18 are 10 12 14 15  
16 17 18



In your last email, you had some of the values given out of order:
1.  20,21-24
2. 21-24,20
3. 10,20,21-24,25,26,30

To make sure the $final values are always ascending, just do this at  
the end:

sort($final);

Done!!

Jordan




On Sep 13, 2005, at 7:16 PM, babu wrote:


$str=10,12,14-18;

$tok = strtok($str, ',');
while ($tok !== false) {
 $toks[] = $tok;
  $tok = strtok(',');
   }

foreach ($toks as $token){
 if (strpos($token,'-')){
  stringtokenize($token);
 }else{
  $finaltokens[]= $token;
  }
}

function stringtokenize($nstr){
 $ntok1= strtok($nstr,'-');
 $ntok2=strtok('-');
 for($i=$ntok1;$i=$ntok2;$i++){
  $finaltokens[]= $i;
  }
 }

foreach ($finaltokens as $ftoken){
 echo $ftoken;
 echo br /;
 }

the ouput prints only 10,12 but not 14,15,16,17,18. where is the  
problem.




-
To help you stay safe and secure online, we've developed the all  
new Yahoo! Security Centre.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whats wrong with this query?

2003-11-10 Thread Raditha Dissanayake
Hi Dave,
I could be wrong cause i am answering without running your code :
1) your mysql user account probably does not have grant privileges. good 
thing too. It's very dangerous to just run a grant query like this 
because it can so easily be abused by a malicious user. (of course you 
might have security measures in place which are not obvious to us 
because you have not posted that part of the code).

2) your variables should in the strictest sense be $_POST['f2'] etc.

all the best

Dave Carrera wrote:

$addamysqluser = mysql_query(grant
select,insert,drop,update,delete,create,index,alter on $_POST[f2] to
[EMAIL PROTECTED] IDENTIFIED by $_POST[f3]);
What is wrong with the above php based mysql_query ?

I am trying to add a user to mysql granting just the specified rights to
table defined by the $_POST[f2] which is both the table and username and the
password is defined by $_POST[f3].
This has been baffleing me for a couple of days now and any help given is
very much appreciated.
Thank you in advance.

Yours
Dave C
 



--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Whats wrong with this query?

2003-11-10 Thread Chris W. Parker
Dave Carrera mailto:[EMAIL PROTECTED]
on Monday, November 10, 2003 8:45 AM said:

 $addamysqluser = mysql_query(grant
 select,insert,drop,update,delete,create,index,alter on $_POST[f2] to
 [EMAIL PROTECTED] IDENTIFIED by $_POST[f3]);
 
 What is wrong with the above php based mysql_query ?

1. What error are you getting? (This information should always be
included in a why isn't this working? post.)
2. How do you know it's not working?
3. Assign your sql statement to a variable and then pass that variable
to the mysql_query() function. Then echo the variable used to store the
query and see if everything looks right to you.
4. Have you tried putting single quotes around the $_POST indexes? i.e.
$_POST['f2']
5. (I believe) You need to put { and } around your $_POST variables.
i.e. {$_POST['f2']}


HTH,
Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whats wrong with this query?

2003-11-10 Thread Chris Shiflett
--- Dave Carrera [EMAIL PROTECTED] wrote:
 $addamysqluser = mysql_query(grant
 select,insert,drop,update,delete,create,index,alter on $_POST[f2] to
 [EMAIL PROTECTED] IDENTIFIED by $_POST[f3]);
 
 What is wrong with the above php based mysql_query?

I'm not sure about the query itself, but it seems to me your problem is
more about using strings with PHP.

$foo = grant select,insert,drop,update,delete,create,index,alter on
$_POST[f2] to [EMAIL PROTECTED] IDENTIFIED by $_POST[f3];
echo $foo;

Try that, and I think the output will show you the problem. The solution
is to use curly braces around $_POST['f2'], in addition to properly
quoting the key as I just did.

In order to more easily identify problems like this, you can:

1. Store the query in a variable, and use that variable in mysql_query().
This will allow you to echo it to the screen or something during
debugging, so that you can identify anything obvious, such as this.

2. Output mysql_error() if mysql_query() does not return true. This will
show you what MySQL thinks the error is, which is very helpful.

Hope that helps.

Chris

=
My Blog
 http://shiflett.org/
HTTP Developer's Handbook
 http://httphandbook.org/
RAMP Training Courses
 http://www.nyphp.org/ramp

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whats wrong with this query?

2003-11-10 Thread Wouter van Vliet
 -Original Message-
 From: Dave Carrera [mailto:[EMAIL PROTECTED] 
 Sent: maandag 10 november 2003 17:45
 To: [EMAIL PROTECTED]
 Subject: [PHP] Whats wrong with this query?
 
 $addamysqluser = mysql_query(grant
 select,insert,drop,update,delete,create,index,alter on $_POST[f2] to
 [EMAIL PROTECTED] IDENTIFIED by $_POST[f3]);
 
 What is wrong with the above php based mysql_query ?
 

The value you use for the IDENTIFIED BY clause (which is, of course, the
password) should be quoted in mysql because it is a value. Both table and
username are sortoff 'objects'. Try this:


$Query = 'GRANT select, insert, drop, update, delete, create, index, alter
ON '.$_POST['f2'].'
TO '.$_POST['f2'].' IDENTIFIED BY
'.mysql_escape_string($_POST['f3']).'';

mysql_query($Query);
if (mysql_error()) print mysql_error();


What I also just noted was that you use $_POST[f2] twice, if you are not
also creating a table with the same name as the user this is probably not
what you meant. It might just, but it looks odd to me.

Wouter

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whats wrong with my code?

2003-09-20 Thread Burhan Khalid
Stevie D Peele wrote:
Can someone spot what Is wrong with my code?
[ trim ]

It says Line 195 which is the ?

Would it matter I don't have all of these files (i.e.
/includes/world.html) were uploaded yet?
Yes it would matter.

You need to use an editor that supports syntax highlighting.

Whenever the error is on the last line, check the line before it.

Like others have suggested, narrow your post down to a test case, never 
send attachments.

--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Whats wrong with my code?

2003-09-20 Thread Jason Sheets
Sounds like you might have an open { somewhere, PHP can't tell that you 
have a problem until it reaches the end of the file.

Jason

Burhan Khalid wrote:

Stevie D Peele wrote:

Can someone spot what Is wrong with my code?


[ trim ]

It says Line 195 which is the ?

Would it matter I don't have all of these files (i.e.
/includes/world.html) were uploaded yet?


Yes it would matter.

You need to use an editor that supports syntax highlighting.

Whenever the error is on the last line, check the line before it.

Like others have suggested, narrow your post down to a test case, 
never send attachments.

--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Whats wrong with my code?

2003-09-17 Thread David T-G
Stevie --

You've already been beaten up about posting tons of code, so I won't add
to that (much, anyway; DON'T, and ABSOLUTELY DON'T 'TOFU' POST!).  And
you've heard that you needed the ; on the last line and to correct your
occasional $includes problems, so that's done.

Yes, you should work on reducing the problem to its minimum cause.  While
a default case is not required for a switch statement, you could have the
same problem by replacing all of those cases with a default -- and then
you not only might find the answer yourself but you also wouldn't take so
much heat for posting so much junk :-)

You should also read the manual to see how to use include().  I'll bet a
twinkie that /includes doesn't exist on your server (who would give a web
site access to files right off of the system root directory??) but am not
going to tell you any more because you should go and look it up yourself.

No, this reply is more about style and tricks.  Your code is long and
difficult to debug because of its sheer bulk, and it needn't be.

I would write your entire 200 (or 151) lines of code as

  ?php
$page = $_GET['id'] ;
if ( is_file(/includes/$page.html) )
  { include(/includes/$page.html) ; }
  ?

if you didn't need to exclude any possibilities or, much more sanely,

  ?php
$includes = array ( home, arts, ...  world) ;
$page = $_GET['id'] ;
if ( in_array($page,$includes)  is_file(/includes/$page.html) )
  { include(/includes/$page.html) ; }
  ?

(just from the top of my head, though, without real thought for security)
and in reality I'd probably not bother with the $page temp variable.

Good luck, and enjoy :-)


HTH  HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


Re: [PHP] Whats wrong with my code?

2003-09-16 Thread Brad Pauly
Stevie D Peele wrote:

[snip]


case world:
 $includes = /includes/world.html;
break;
}

include ($include)
?


It says Line 195 which is the ?

Would it matter I don't have all of these files (i.e.
/includes/world.html) were uploaded yet?
Yeah. You need a ; at the end of the line before that. Like:

include ($include);

You also use $includes in a couple of the cases, like the last one.

- Brad

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Whats wrong with my code?

2003-09-16 Thread Craig Lonsbury
no semicolon after include ($include)


hope that helps,
Craig

-Original Message-
From: Stevie D Peele [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 16, 2003 3:11 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Whats wrong with my code?


Can someone spot what Is wrong with my code?



?php
$page = $_GET['id'];
switch ($page) 
{
case home:
$include = /includes/index.html;
break;

case arts:
 $include = /includes/arts.html;
break;

case aaexpert:
 $include = /includes/aaexpert.html;
break;

case career:
 $include = /includes/career.html;
break;

case comics:
 $include = /includes/comics.html;
break;

case graphics:
 $include = /includes/graphics.html;
break;

case computers:
 $include = includes/computers.html;
break;

case consumers:
 $include = /includes/consumer.html;
break;

case dailies:
 $include = /includes/dailies.html;
break;

case forums:
 $include = /includes/forums.html;
break;

case downloads:
 $include = /includes/downloads.html;
break;

case editors:
 $include = /includes/editors.html;
break;

case educational:
 $include = /includes/educational.html;
break;

case electronics:
 $include = /includes/electronics.html;
break;

case entertainment:
 $include = /includes/entertainment.html;
break;

case shopping:
 $include = /includes/shopping.html;
break;

case free:
 $include = /includes/freetime.html;
break;

case government:
 $include = /includes/government.html;
break;

case governments:
 $includes = /includes/governments.html;
break;

case healthnews:
 $includes = /includes/healthnews.html;
break;

case homegarden:
 $includes = /includes/homegarden.html;
break;

case homework:
 $includes = /includes/homework.html;
break;

case stuffworks:
 $includes = /includes/hsworks.html;
break;

case inthenews:
 $includes = /includes/inthenews.html;
break;

case infokiosk:
 $includes = /includes/kiosk.html;
break;

case knowledge:
 $includes = /includes/builder.html;
break;

case money:
 $includes = /includes/money.html;
break;

case yahoo:
 $includes = /includes/yahoo.html;
break;

case museums:
 $includes = /includes/museums.html;
break;

case othernews:
 $includes = /includes/othernews.html;
break;

case pictures:
 $includes = /includes/pictures.html;
break;

case politics:
 $includes = includes/politics.html;
break;

case quotations:
$includes = /includes/quotes.html;
break;

case recreation:
 $includes = /includes/recreation.html;
break;

case reference:
 $includes = /includes/reference.html;
break;

case reviews:
 $includes = /includes/reviews.html;
break;

case search:
 $includes = /includes/search.html;
break;

case society:
 $include = /includes/society.html;
break;

case sports:
 $include = /includes/sportsnews.html;
break;

case studyhelp:
 $include = /includes/study.html;
break;

case travel:
 $include = /includes/travel.html;
break;

case USA:
 $includes = /includes/usa.html;
break;

case USNews:
 $includes = includes/usnews.html;
break;

case weather:
 $includes = /includes/weather.html;
break;

case webmaster:
$includes = /includes/webmaster.html;
break;

case goodbad:
 $includes = /includes/goodbad.html;
break;

case world:
 $includes = /includes/world.html;
break;
}

include ($include)
?



It says Line 195 which is the ?

Would it matter I don't have all of these files (i.e.
/includes/world.html) were uploaded yet?

Thanks,

Stevie

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whats wrong with my code?

2003-09-16 Thread Chris Shiflett
--- Stevie D Peele [EMAIL PROTECTED] wrote:
 Can someone spot what Is wrong with my code?

It is about 200 lines of redundant crap and posted to a mailing list?

Please be considerate and try to narrow your code down to the smallest case
that demonstrates the problem. We are not here to debug your code. Your code
can be summarized as:

?
switch ($_GET['id']) 
{
 default:
  $include = '/includes/index.html';
  break;
}
include ($include);
?

Does this code have the same problem in your environment? Are you saving files
with \n\r line termination and trying to execute the code from a Unix
environment?

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whats wrong with my code?

2003-09-16 Thread Matthias Nothhaft
Hi Stevie D Peele, you wrote:
Can someone spot what Is wrong with my code?

Please read your code carefully and check the
writing of your variable $include!
Sometimes you write $includes instead...

It has to have the same name everywhere,
PHP can't guess what you want ;-)
What is the certain error message?

And yes: if the file doesn't exists that should be included
PHP will not be happy about it.
PHP can't also guess what code is in the file you wanna include ;-)

Regards,
Matthias


?php
$page = $_GET['id'];
switch ($page) 
{
case home:
$include = /includes/index.html;
break;

case arts:
 $include = /includes/arts.html;
break;
case aaexpert:
 $include = /includes/aaexpert.html;
break;
case career:
 $include = /includes/career.html;
break;
case comics:
 $include = /includes/comics.html;
break;
case graphics:
 $include = /includes/graphics.html;
break;
case computers:
 $include = includes/computers.html;
break;
case consumers:
 $include = /includes/consumer.html;
break;
case dailies:
 $include = /includes/dailies.html;
break;
case forums:
 $include = /includes/forums.html;
break;
case downloads:
 $include = /includes/downloads.html;
break;
case editors:
 $include = /includes/editors.html;
break;
case educational:
 $include = /includes/educational.html;
break;
case electronics:
 $include = /includes/electronics.html;
break;
case entertainment:
 $include = /includes/entertainment.html;
break;
case shopping:
 $include = /includes/shopping.html;
break;
case free:
 $include = /includes/freetime.html;
break;
case government:
 $include = /includes/government.html;
break;
case governments:
 $includes = /includes/governments.html;
break;
case healthnews:
 $includes = /includes/healthnews.html;
break;
case homegarden:
 $includes = /includes/homegarden.html;
break;
case homework:
 $includes = /includes/homework.html;
break;
case stuffworks:
 $includes = /includes/hsworks.html;
break;
case inthenews:
 $includes = /includes/inthenews.html;
break;
case infokiosk:
 $includes = /includes/kiosk.html;
break;
case knowledge:
 $includes = /includes/builder.html;
break;
case money:
 $includes = /includes/money.html;
break;
case yahoo:
 $includes = /includes/yahoo.html;
break;
case museums:
 $includes = /includes/museums.html;
break;
case othernews:
 $includes = /includes/othernews.html;
break;
case pictures:
 $includes = /includes/pictures.html;
break;
case politics:
 $includes = includes/politics.html;
break;
case quotations:
$includes = /includes/quotes.html;
break;
case recreation:
 $includes = /includes/recreation.html;
break;
case reference:
 $includes = /includes/reference.html;
break;
case reviews:
 $includes = /includes/reviews.html;
break;
case search:
 $includes = /includes/search.html;
break;
case society:
 $include = /includes/society.html;
break;
case sports:
 $include = /includes/sportsnews.html;
break;
case studyhelp:
 $include = /includes/study.html;
break;
case travel:
 $include = /includes/travel.html;
break;
case USA:
 $includes = /includes/usa.html;
break;
case USNews:
 $includes = includes/usnews.html;
break;
case weather:
 $includes = /includes/weather.html;
break;
case webmaster:
$includes = /includes/webmaster.html;
break;
case goodbad:
 $includes = /includes/goodbad.html;
break;
case world:
 $includes = /includes/world.html;
break;
}

include ($include)
?


It says Line 195 which is the ?

Would it matter I don't have all of these files (i.e.
/includes/world.html) were uploaded yet?
Thanks,

Stevie
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Whats wrong with my code?

2003-09-16 Thread Dan J. Rychlik
Your missing your default for your case switch statement

And you ; at the end of line on your last include statement..

-Dan



- Original Message - 
From: Stevie D Peele [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, September 16, 2003 4:10 PM
Subject: [PHP] Whats wrong with my code?


 Can someone spot what Is wrong with my code?
 
 
 
 ?php
 $page = $_GET['id'];
 switch ($page) 
 {
 case home:
 $include = /includes/index.html;
 break;
 
 case arts:
  $include = /includes/arts.html;
 break;
 
 case aaexpert:
  $include = /includes/aaexpert.html;
 break;
 
 case career:
  $include = /includes/career.html;
 break;
 
 case comics:
  $include = /includes/comics.html;
 break;
 
 case graphics:
  $include = /includes/graphics.html;
 break;
 
 case computers:
  $include = includes/computers.html;
 break;
 
 case consumers:
  $include = /includes/consumer.html;
 break;
 
 case dailies:
  $include = /includes/dailies.html;
 break;
 
 case forums:
  $include = /includes/forums.html;
 break;
 
 case downloads:
  $include = /includes/downloads.html;
 break;
 
 case editors:
  $include = /includes/editors.html;
 break;
 
 case educational:
  $include = /includes/educational.html;
 break;
 
 case electronics:
  $include = /includes/electronics.html;
 break;
 
 case entertainment:
  $include = /includes/entertainment.html;
 break;
 
 case shopping:
  $include = /includes/shopping.html;
 break;
 
 case free:
  $include = /includes/freetime.html;
 break;
 
 case government:
  $include = /includes/government.html;
 break;
 
 case governments:
  $includes = /includes/governments.html;
 break;
 
 case healthnews:
  $includes = /includes/healthnews.html;
 break;
 
 case homegarden:
  $includes = /includes/homegarden.html;
 break;
 
 case homework:
  $includes = /includes/homework.html;
 break;
 
 case stuffworks:
  $includes = /includes/hsworks.html;
 break;
 
 case inthenews:
  $includes = /includes/inthenews.html;
 break;
 
 case infokiosk:
  $includes = /includes/kiosk.html;
 break;
 
 case knowledge:
  $includes = /includes/builder.html;
 break;
 
 case money:
  $includes = /includes/money.html;
 break;
 
 case yahoo:
  $includes = /includes/yahoo.html;
 break;
 
 case museums:
  $includes = /includes/museums.html;
 break;
 
 case othernews:
  $includes = /includes/othernews.html;
 break;
 
 case pictures:
  $includes = /includes/pictures.html;
 break;
 
 case politics:
  $includes = includes/politics.html;
 break;
 
 case quotations:
 $includes = /includes/quotes.html;
 break;
 
 case recreation:
  $includes = /includes/recreation.html;
 break;
 
 case reference:
  $includes = /includes/reference.html;
 break;
 
 case reviews:
  $includes = /includes/reviews.html;
 break;
 
 case search:
  $includes = /includes/search.html;
 break;
 
 case society:
  $include = /includes/society.html;
 break;
 
 case sports:
  $include = /includes/sportsnews.html;
 break;
 
 case studyhelp:
  $include = /includes/study.html;
 break;
 
 case travel:
  $include = /includes/travel.html;
 break;
 
 case USA:
  $includes = /includes/usa.html;
 break;
 
 case USNews:
  $includes = includes/usnews.html;
 break;
 
 case weather:
  $includes = /includes/weather.html;
 break;
 
 case webmaster:
 $includes = /includes/webmaster.html;
 break;
 
 case goodbad:
  $includes = /includes/goodbad.html;
 break;
 
 case world:
  $includes = /includes/world.html;
 break;
 }
 
 include ($include)
 ?
 
 
 
 It says Line 195 which is the ?
 
 Would it matter I don't have all of these files (i.e.
 /includes/world.html) were uploaded yet?
 
 Thanks,
 
 Stevie

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whats wrong with my code?

2003-09-16 Thread Stevie D Peele




Okay, I took all the extra spaces out of my code, So it is now 151 lines. 


I have attached that code, instead of posting it in my mail. It says 



Warning: Unable to access /includes/home.html in 
/usr/local/psa/home/vhosts/net-riches.com/httpdocs/includes/category.php 
on line 150Warning: Failed opening '/includes/home.html' 
for inclusion (include_path='.:/usr/local/psa/apache/lib/php') in 
/usr/local/psa/home/vhosts/net-riches.com/httpdocs/includes/category.php 
on line 150



In the code, line 150 is the line where 'include ($include);' is (without 
the quotes)...

Thanks for all your help


Stevie


On Tue, 16 Sep 2003 16:44:25 -0500 "Dan J. Rychlik" [EMAIL PROTECTED] 
writes: Your missing your default for your case switch statement 
 And you ; at the end of line on your last include statement.. 
 -Dan- Original Message - 
 From: "Stevie D Peele" [EMAIL PROTECTED] To: [EMAIL PROTECTED] 
Sent: Tuesday, September 16, 2003 4:10 PM Subject: [PHP] Whats wrong 
with my code?Can someone spot what Is wrong with 
my code??php 
 $page = $_GET['id'];  switch ($page)   { 
 case "home": 
 $include = 
"/includes/index.html";  break;  
  case "arts":  $include = 
"/includes/arts.html";  break;  
  case "aaexpert":  
$include = "/includes/aaexpert.html";  
break;case "career": 
 $include = "/includes/career.html"; 
 break;   
 case "comics":  $include = 
"/includes/comics.html";  break; 
   case "graphics":  
$include = "/includes/graphics.html";  
break;case 
"computers":  $include = "includes/computers.html"; 
 break;   
 case "consumers":  $include = 
"/includes/consumer.html";  break; 
   case "dailies":  
$include = "/includes/dailies.html";  
break;case "forums": 
 $include = "/includes/forums.html"; 
 break;   
 case "downloads":  $include = 
"/includes/downloads.html";  break; 
   case "editors":  
$include = "/includes/editors.html";  
break;case 
"educational":  $include = 
"/includes/educational.html";  
break;case 
"electronics":  $include = 
"/includes/electronics.html";  
break;case 
"entertainment":  $include = 
"/includes/entertainment.html";  
break;case 
"shopping":  $include = "/includes/shopping.html"; 
 break;   
 case "free":  $include = 
"/includes/freetime.html";  break; 
   case "government":  
$include = "/includes/government.html";  
break;case 
"governments":  $includes = 
"/includes/governments.html";  
break;case 
"healthnews":  $includes = 
"/includes/healthnews.html";  break; 
   case "homegarden":  
$includes = "/includes/homegarden.html";  
break;case 
"homework":  $includes = "/includes/homework.html"; 
 break;   
 case "stuffworks":  $includes = 
"/includes/hsworks.html";  break; 
   case "inthenews":  
$includes = "/includes/inthenews.html";  
break;case 
"infokiosk":  $includes = "/includes/kiosk.html"; 
 break;   
 case "knowledge":  $includes = 
"/includes/builder.html";  break; 
   case "money":  
$includes = "/includes/money.html";  
break;case "yahoo": 
 $includes = "/includes/yahoo.html"; 
 break;   
 case "museums":  $includes = 
"/includes/museums.html";  break; 
   case "othernews":  
$includes = "/includes/othernews.html";  
break;case 
"pictures":  $includes = "/includes/pictures.html"; 
 break;   
 case "politics":  $includes = 
"includes/politics.html";  break; 
   case "quotations": 
 $includes = 
"/includes/quotes.html";  break; 
   case "recreation":  
$includes = "/includes/recreation.html";  
break;case 
"reference":  $includes = "/includes/reference.html"; 
 break;   
 case "reviews":  $includes = 
"/includes/reviews.html";  break; 
   case "search":  
$includes = "/includes/search.html";  
break;case 
"society":  $include = "/includes/society.html"; 
 break;   
 case "sports":  $include = 
"/includes/sportsnews.html";  break; 
   case "studyhelp":  
$include = "/includes/study.html";  
break;case "travel": 
 $include = "/includes/travel.html"; 
 break;   
 case "USA":  $includes = 
"/includes/usa.html";  break;  
  case "USNews":  
$includes = "includes/usnews.html";  
break;case 
"weather":  $includes = "/includes/weather.html"; 
 break;   
 case "webmaster": 
 $includes = 
"/includes/webmaster.html";  break; 
   case "goodbad":  
$includes = "/includes/goodbad.html";  
break;case "world": 
 $includes = "/includes/world.html"; 
 break;   } 
   include ($include)  ?   
 It says Line 195 which is the ? 
   Would it matter I don't have all of these files (i.e. 
 /includes/world.html) were uploaded yet?
Thanks,Stevie  --  PHP 
General Mailing List (http://www.php.net/) To unsubscribe, 
visit: http://www.php.net/unsub.php 
  


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Whats wrong with my code?

2003-09-16 Thread Chris W. Parker
Stevie D Peele mailto:[EMAIL PROTECTED]
on Tuesday, September 16, 2003 4:08 PM said:

 Okay, I took all the extra spaces out of my code, So it is now 151
 lines. 
 
 I have attached that code, instead of posting it in my mail. It says

Attachments are even worse. I'll never open an attachment I receive on a
list.

1. Don't post tons of code
2. Don't send attachments.
3. Trim your posts!



Chris.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whats wrong with my code?

2003-09-16 Thread Chris Shiflett
--- Stevie D Peele [EMAIL PROTECTED] wrote:
 Okay, I took all the extra spaces out of my code, So it is now
 151 lines.

I appreciate you trying to trim down your code. However, it isn't the
whitespace that is superfluous. You now have 151 lines that are mostly
repeating the same basic assignment; it's the same problem. It makes it look as
if you have not put forth any effort to try and solve this problem.

Remember that the people who answer questions on this list do so voluntarily
and can't afford to waste a lot of time searching through all of your code to
find a missing semicolon or something of the like. As I mentioned earlier, this
list is not the place to have someone debug your code.

So, when you have a problem with your code, you will find people much more
willing to help if you can reproduce the problem in a very small sample. In
many cases, you may also discover your own problem and not even need to ask.

 I have attached that code, instead of posting it in my mail.

I generally delete anything posted to this list with an attachment. I'm sure
many people do. Also, because you quoted the entire message from before, you
have all of your 200 lines of code in the email, and then you attach the whole
thing again. That's even worse.

 Warning: Unable to access /includes/home.html in
 /usr/local/psa/home/vhosts/net-riches.com/httpdocs/includes/category.php
 on line 150
 
 Warning: Failed opening '/includes/home.html' for inclusion
 (include_path='.:/usr/local/psa/apache/lib/php') in
 /usr/local/psa/home/vhosts/net-riches.com/httpdocs/includes/category.php
 on line 150

I bet you could reproduce this problem with the following code:

include('/includes/home.html');

That 1 line demonstrates the same problem that your 151 lines do. Have you
looked to see if /includes/home.html exists?

Hope that helps.

Chris

=
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whats wrong?

2003-09-13 Thread Ryan A
Hey,
Just touched it up a bit but its working:

title
?php
$senderemail = $_POST['from'];
print Thank You, $senderemail;
?
/title

This should come before:
$senderemail = $_POST['from'];

not after this:
print Thank You, $senderemail;

plus

I'm guessing that either your form is sending $senderemail  or that you are
getting via a $_GET

you have to post $from not $senderemail.

If you change the above to a $_GET this will work
YourFileName.php?from=Ryan

Cheers,
-Ryan




We will slaughter you all! - The Iraqi (Dis)information ministers site
http://MrSahaf.com


- Original Message - 
From: Stevie D Peele [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, September 13, 2003 2:45 PM
Subject: [PHP] Whats wrong?


 Whats wrong with this

 title?php echo Thank You, $senderemail; ?/title

 where

 $senderemail = $_POST['from'];

 It doesnt It only echos thank you.

 Why?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Whats wrong?

2003-09-13 Thread Sid
Try this

title?echo Thank You, .$_POST['from']; ?/title

- Sid

On Sat, 13 Sep 2003 08:45:16 -0400, Stevie D Peele wrote:
 Whats wrong with this


 title?php echo Thank You, $senderemail; ?/title


 where


 $senderemail = $_POST['from'];


 It doesnt It only echos thank you.


 Why?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Whats wrong?

2003-09-13 Thread esctoday.com | Wouter van Vliet
or even:

title?=(Thank you, $_POST[from])?/title

:P

 - -Oorspronkelijk bericht-
 - Van: Sid [mailto:[EMAIL PROTECTED]
 - Verzonden: zondag 14 september 2003 3:43
 - Aan: Stevie D Peele; [EMAIL PROTECTED]
 - Onderwerp: Re: [PHP] Whats wrong?
 - 
 - 
 - Try this
 - 
 - title?echo Thank You, .$_POST['from']; ?/title
 - 
 - - Sid
 - 
 - On Sat, 13 Sep 2003 08:45:16 -0400, Stevie D Peele wrote:
 -  Whats wrong with this
 - 
 - 
 -  title?php echo Thank You, $senderemail; ?/title
 - 
 - 
 -  where
 - 
 - 
 -  $senderemail = $_POST['from'];
 - 
 - 
 -  It doesnt It only echos thank you.
 - 
 - 
 -  Why?
 - 
 - -- 
 - PHP General Mailing List (http://www.php.net/)
 - To unsubscribe, visit: http://www.php.net/unsub.php
 - 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] whats wrong with this?

2002-08-28 Thread Hankley, Chip

you need to use == instead of =

== is used when comparing values (i.e. is this == to that)
= is used to set something's value (i.e. this = that)

-chip

-Original Message-
From: Chris Barnes [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 28, 2002 11:12 AM
To: Php-General (E-mail)
Subject: [PHP] whats wrong with this?


I just cant seem to work out why this doesn't work. My PHP book doesn't
explain if statements very well so i have no idea if i am breaking a rule.

$system_day = date(j);

for($day = 1; $day  32; $day++){
if($day = $system_day){
echo match!;
}

else{
echo no match;
}
}

the problem i am experiencing is that it seems the if statement is setting
the $day value to equal $system_day instead of comparing their values
if i add

echo Day:  . $day .  System_day:  . $system_day;

before and after the if statement then the first result is something like

Day: 1 System_day: 29

after the if statement has executed the result is

Day: 29 System_day: 29

so you see, instead of if comparing $day to $system_day it is making $day
equal to $system_day.

any ideas why and how to fix this?

help is most appreciated :)


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] whats wrong with this?

2002-08-28 Thread Richard Black

A single = will assing a value, even inside an if statement

A double = (ie ==) will perform a comparison between 2 values, returning
true if they evaluate to the same value, false otherwise

A triple = (===) will do the same as ==, but also check that the types
of the 2 variables match.

Check out the PHP manual - http://www.php.net/manual/ - for more info

HTH,

Richy

==
Richard Black
Systems Programmer, DataVisibility Ltd - http://www.datavisibility.com
Tel: 0141 435 3504
Email: [EMAIL PROTECTED] 

-Original Message-
From: Chris Barnes [mailto:[EMAIL PROTECTED]] 
Sent: 28 August 2002 17:12
To: Php-General (E-mail)
Subject: [PHP] whats wrong with this?


I just cant seem to work out why this doesn't work. My PHP book doesn't
explain if statements very well so i have no idea if i am breaking a
rule.

$system_day = date(j);

for($day = 1; $day  32; $day++){
if($day = $system_day){
echo match!;
}

else{
echo no match;
}
}

the problem i am experiencing is that it seems the if statement is
setting the $day value to equal $system_day instead of comparing their
values if i add

echo Day:  . $day .  System_day:  . $system_day;

before and after the if statement then the first result is something
like

Day: 1 System_day: 29

after the if statement has executed the result is

Day: 29 System_day: 29

so you see, instead of if comparing $day to $system_day it is making
$day equal to $system_day.

any ideas why and how to fix this?

help is most appreciated :)


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] whats wrong with this?

2002-08-28 Thread Liam . Gibbs

(1) for($day = 1; $day  32; $day++){
(2) if($day = $system_day){
(3) echo match!;
(4) }
.
.
.

Easy enough. One of those things the programmer may not spot, but a casual
observer might. In line #2, you have a single =. A comparative = is a double
equal (==). The line should read if($day == $system_day){. A single equal
will assign the value; a double equal will compare the two.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] whats wrong with this function

2002-07-03 Thread 1LT John W. Holmes

Yes, your problem is it doesn't work.

HTH,
---John Holmes...

PS: Think that's a worthless answer? Well...same for your question...

- Original Message -
From: Adrian Murphy [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, July 03, 2002 8:47 AM
Subject: [PHP] whats wrong with this function



whats wrong with this.
it's getting stuck somewhere



function urls_clickable($string) {
for($n=0; $n  strlen($string); $n++)
{
if(strtolower($string[$n]) == 'h') {
if(!strcmp(http://;, strtolower($string[$n]) . strtolower($string[$n+1]) .
strtolower($string[$n+2]) . strtolower($string[$n+3]) . $string[$n+4] .
$string[$n+5] . $string[$n+6])) {
$startpos = $n;
while($n  strlen($string)  eregi([a-z0-9\.\:\?\/\~\-\_\\=\%\+\'\],
$string[$n])) $n++;
if(!eregi([a-z0-9], $string[$n-1])) $n--;
$link = substr($string, $startpos, ($n-$startpos));
$link = $link;
$string_tmp = $string;
$string = substr($string_tmp, 0, $startpos);
$string .= a href=\$link\ target=\_blank\$link/a;
$string .= substr($string_tmp, $n, strlen($string_tmp));
$n = $n + 15;
}
}
}
return $string;
}

$text = http://www.somewhere.org brbr;
echo urls_clickable($text);



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] whats wrong with this function

2002-07-03 Thread Jason Wong

On Wednesday 03 July 2002 20:47, Adrian Murphy wrote:
 whats wrong with this.
 it's getting stuck somewhere

Stick in some echo statements at strategic points in the loops to find out 
_where_ it is getting stuck.

 function urls_clickable($string) {
 for($n=0; $n  strlen($string); $n++)
 {
 if(strtolower($string[$n]) == 'h') {
 if(!strcmp(http://;, strtolower($string[$n]) . strtolower($string[$n+1]) .
 strtolower($string[$n+2]) . strtolower($string[$n+3]) . $string[$n+4] .
 $string[$n+5] . $string[$n+6])) { $startpos = $n;
 while($n  strlen($string)  eregi([a-z0-9\.\:\?\/\~\-\_\\=\%\+\'\],
 $string[$n])) $n++; if(!eregi([a-z0-9], $string[$n-1])) $n--;
 $link = substr($string, $startpos, ($n-$startpos));
 $link = $link;
 $string_tmp = $string;
 $string = substr($string_tmp, 0, $startpos);
 $string .= a href=\$link\ target=\_blank\$link/a;
 $string .= substr($string_tmp, $n, strlen($string_tmp));
 $n = $n + 15;
 }
 }
 }
 return $string;
 }

 $text = http://www.somewhere.org brbr;
 echo urls_clickable($text);


-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
System going down at 1:45 this afternoon for disk crashing.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] whats wrong with this function

2002-07-03 Thread Adrian Murphy

relax friend.i was just asking

- Original Message -
From: 1LT John W. Holmes [EMAIL PROTECTED]
To: Adrian Murphy [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Wednesday, July 03, 2002 2:08 PM
Subject: Re: [PHP] whats wrong with this function


 Yes, your problem is it doesn't work.

 HTH,
 ---John Holmes...

 PS: Think that's a worthless answer? Well...same for your question...

 - Original Message -
 From: Adrian Murphy [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, July 03, 2002 8:47 AM
 Subject: [PHP] whats wrong with this function



 whats wrong with this.
 it's getting stuck somewhere



 function urls_clickable($string) {
 for($n=0; $n  strlen($string); $n++)
 {
 if(strtolower($string[$n]) == 'h') {
 if(!strcmp(http://;, strtolower($string[$n]) . strtolower($string[$n+1])
.
 strtolower($string[$n+2]) . strtolower($string[$n+3]) . $string[$n+4] .
 $string[$n+5] . $string[$n+6])) {
 $startpos = $n;
 while($n  strlen($string)  eregi([a-z0-9\.\:\?\/\~\-\_\\=\%\+\'\],
 $string[$n])) $n++;
 if(!eregi([a-z0-9], $string[$n-1])) $n--;
 $link = substr($string, $startpos, ($n-$startpos));
 $link = $link;
 $string_tmp = $string;
 $string = substr($string_tmp, 0, $startpos);
 $string .= a href=\$link\ target=\_blank\$link/a;
 $string .= substr($string_tmp, $n, strlen($string_tmp));
 $n = $n + 15;
 }
 }
 }
 return $string;
 }

 $text = http://www.somewhere.org brbr;
 echo urls_clickable($text);



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] whats wrong with this function

2002-07-03 Thread Stuart Dallas

On Wednesday, July 3, 2002, 1:47:05 PM, Adrian Murphy wrote:
 whats wrong with this.
 it's getting stuck somewhere

Somewhere isn't very helpful. When asking for help be sure to include as much
information as possilble.

Laying out your code so the structure can be seen...

?php
function urls_clickable($string)
{
  for($n=0; $n  strlen($string); $n++)
  {
if(strtolower($string[$n]) == 'h')
{
  if(!strcmp(http://;, strtolower($string[$n]) . strtolower($string[$n+1]) . 
strtolower($string[$n+2]) . strtolower($string[$n+3]) . $string[$n+4] . $string[$n+5] 
. $string[$n+6]))
  {
$startpos = $n;

while($n  strlen($string)  eregi([a-z0-9\.\:\?\/\~\-\_\\=\%\+\'\], 
$string[$n]))
  $n++;

if(!eregi([a-z0-9], $string[$n-1]))
  $n--;

$link = substr($string, $startpos, ($n-$startpos));
$link = $link;
$string_tmp = $string;
$string = substr($string_tmp, 0, $startpos);
$string .= a href=\$link\ target=\_blank\$link/a;
$string .= substr($string_tmp, $n, strlen($string_tmp));
$n = $n + 15;
  }
}
  }
  return $string;
}

$text = http://www.somewhere.org brbr;
echo urls_clickable($text);
?

It's getting stuck because you're moving the goalposts. It's a very bad idea to
base a loop on a variable that is changed within the loop. I suggest you loop
through one string while building a second string as the return value.

On the other hand, I seem to remember seeing a regex posted on this list
recently that did exactly this. I suggest you search the archives for it
because it would save you a lot of hassle.

-- 
Stuart


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] whats wrong with this function

2002-07-03 Thread Adrian Murphy

thnks,
i didn't write the function so i've now replaced it
with something better.
- Original Message -
From: Stuart Dallas [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, July 03, 2002 2:30 PM
Subject: Re: [PHP] whats wrong with this function


 On Wednesday, July 3, 2002, 1:47:05 PM, Adrian Murphy wrote:
  whats wrong with this.
  it's getting stuck somewhere

 Somewhere isn't very helpful. When asking for help be sure to include as
much
 information as possilble.

 Laying out your code so the structure can be seen...

 ?php
 function urls_clickable($string)
 {
   for($n=0; $n  strlen($string); $n++)
   {
 if(strtolower($string[$n]) == 'h')
 {
   if(!strcmp(http://;, strtolower($string[$n]) .
strtolower($string[$n+1]) . strtolower($string[$n+2]) .
strtolower($string[$n+3]) . $string[$n+4] . $string[$n+5] . $string[$n+6]))
   {
 $startpos = $n;

 while($n  strlen($string) 
eregi([a-z0-9\.\:\?\/\~\-\_\\=\%\+\'\], $string[$n]))
   $n++;

 if(!eregi([a-z0-9], $string[$n-1]))
   $n--;

 $link = substr($string, $startpos, ($n-$startpos));
 $link = $link;
 $string_tmp = $string;
 $string = substr($string_tmp, 0, $startpos);
 $string .= a href=\$link\ target=\_blank\$link/a;
 $string .= substr($string_tmp, $n, strlen($string_tmp));
 $n = $n + 15;
   }
 }
   }
   return $string;
 }

 $text = http://www.somewhere.org brbr;
 echo urls_clickable($text);
 ?

 It's getting stuck because you're moving the goalposts. It's a very bad
idea to
 base a loop on a variable that is changed within the loop. I suggest you
loop
 through one string while building a second string as the return value.

 On the other hand, I seem to remember seeing a regex posted on this list
 recently that did exactly this. I suggest you search the archives for it
 because it would save you a lot of hassle.

 --
 Stuart


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] whats wrong?

2001-07-31 Thread Jeff Lewis

Remove the quotes around $uid

Jeff
- Original Message - 
From: Jeremy Morano [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, July 31, 2001 11:09 AM
Subject: [PHP] whats wrong?


 Anythig visibly wrong with this?
 
 
 FORM METHOD=post ACTION=userinfolistbycompany2.php
 INPUT TYPE=hidden name=uid value=? echo $uid; ?
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] whats wrong?

2001-07-31 Thread Matt Greer

on 7/31/01 10:09 AM, Jeremy Morano at [EMAIL PROTECTED] wrote:

 Anythig visibly wrong with this?
 
 
 FORM METHOD=post ACTION=userinfolistbycompany2.php
 INPUT TYPE=hidden name=uid value=? echo $uid; ?

The quotes around $uid are ending value prematurely. html thinks value is
? echo 

Just drop the quotes around $uid.

Matt


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] whats wrong

2001-07-24 Thread Don Read


On 24-Jul-2001 Jeremy Morano wrote:
 Whats wrong with this?
 
 
 $sql = INSERT INTO $table_name
 (uid,companyUid, first_name, last_name, address, state, zip_code, country,
 company, occupation, telephone, fax, email, user_name, password)
 SELECT
 \\, \uid from companyTable WHERE company= Itsolutions\,
 \$first_name\,\$last_name\,\$address\,\$state\,\$zip_code\,\$coun
 try\,\$company\, \$occupation\, \$telephone\, \$fax\, \$email\,
 \$user_name\, \$password\
 ;
 

A. It's un-readable.
B. you prolly did'nt test | display the error message.


Change your \ to ' and the problem is obvious
(spoiler: 'WHERE' comes after the field list).

Regards,
-- 
Don Read   [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Whats wrong with this code?

2001-07-22 Thread Tom Carter

do you mean..

$message = $IP. $PORT. $SYSTEM . $PAGE; 

. not ,

$message = $IP, $PORT, $SYSTEM, $PAGE; 





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Whats wrong with this code?

2001-07-16 Thread Rasmus Lerdorf

 Hi all, Im getting mighty frustrated with this peice of code. It checks the
 first condition no probs, but the second IF statement doesnt work. So it
 will stop if it finds a du[plicate login, but cannot find duplicate
 passwords. the $num_rows2 variable always gets the value '0' even when there
 is an existing password the same as the new user-entered value.

 $result = mysql_query(SELECT * FROM  Login_TB where Login='$Login',$db) or
 die (ouch);

  $num_rows = mysql_num_rows($result);

 $query2 = select * FROM Team_Login_TB where Pass = password('$Pass');
   $result2 = mysql_query($query2,$db) or die (ouch2);
  $num_rows2 = mysql_num_rows($result2);

Your second query must not be returning any rows.  Print out $query2 and
paste the string you see into the command line mysql tool and execute the
query.  I bet it will return 0 rows.

-Rasmus



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Whats wrong with this code?

2001-07-16 Thread Brad Wright

Rasmus,
you are dead right, it is returning 0 rows. I checked that before
submiytting the original post. Sorry, i should have mentioned it. I guess
the question is, why is it returning no rows?

 From: Rasmus Lerdorf [EMAIL PROTECTED]
 Date: Mon, 16 Jul 2001 19:56:29 -0700 (PDT)
 To: Brad Wright [EMAIL PROTECTED]
 Cc: PHP General List [EMAIL PROTECTED]
 Subject: Re: [PHP] Whats wrong with this code?
 
 Hi all, Im getting mighty frustrated with this peice of code. It checks the
 first condition no probs, but the second IF statement doesnt work. So it
 will stop if it finds a du[plicate login, but cannot find duplicate
 passwords. the $num_rows2 variable always gets the value '0' even when there
 is an existing password the same as the new user-entered value.
 
 $result = mysql_query(SELECT * FROM  Login_TB where Login='$Login',$db) or
 die (ouch);
 
 $num_rows = mysql_num_rows($result);
 
 $query2 = select * FROM Team_Login_TB where Pass = password('$Pass');
 $result2 = mysql_query($query2,$db) or die (ouch2);
 $num_rows2 = mysql_num_rows($result2);
 
 Your second query must not be returning any rows.  Print out $query2 and
 paste the string you see into the command line mysql tool and execute the
 query.  I bet it will return 0 rows.
 
 -Rasmus
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Whats wrong with this code?

2001-07-16 Thread David Robley

On Tue, 17 Jul 2001 12:37, Brad Wright wrote:
  From: Rasmus Lerdorf [EMAIL PROTECTED]
  Date: Mon, 16 Jul 2001 19:56:29 -0700 (PDT)
  To: Brad Wright [EMAIL PROTECTED]
  Cc: PHP General List [EMAIL PROTECTED]
  Subject: Re: [PHP] Whats wrong with this code?
 
  Hi all, Im getting mighty frustrated with this peice of code. It
  checks the first condition no probs, but the second IF statement
  doesnt work. So it will stop if it finds a du[plicate login, but
  cannot find duplicate passwords. the $num_rows2 variable always gets
  the value '0' even when there is an existing password the same as
  the new user-entered value.
 
  $result = mysql_query(SELECT * FROM  Login_TB where
  Login='$Login',$db) or die (ouch);
 
  $num_rows = mysql_num_rows($result);
 
  $query2 = select * FROM Team_Login_TB where Pass =
  password('$Pass'); $result2 = mysql_query($query2,$db) or die
  (ouch2);
  $num_rows2 = mysql_num_rows($result2);
 
  Your second query must not be returning any rows.  Print out $query2
  and paste the string you see into the command line mysql tool and
  execute the query.  I bet it will return 0 rows.
 
  -Rasmus

 Rasmus,
 you are dead right, it is returning 0 rows. I checked that before
 submiytting the original post. Sorry, i should have mentioned it. I
 guess the question is, why is it returning no rows?

This might be too obvious, but are you looking in the correct table? Your 
second query searches a different table from the first? Alternatively, 
you might be getting something you don't expect in $Pass.


-- 
David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA  

   1200 bps used to seem so fast

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Whats wrong with this code?

2001-07-16 Thread Rasmus Lerdorf

 Rasmus,
 you are dead right, it is returning 0 rows. I checked that before
 submiytting the original post. Sorry, i should have mentioned it. I guess
 the question is, why is it returning no rows?

Uh, that is something we can't answer without having access to your actual
data.

-Rasmus


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Whats wrong with this code?

2001-07-16 Thread Brad Wright

Yep, I realise there was a discrepancy in the table names. That wasnt the
issue , i reposted the corrected code as soon as i realised.

 From: David Robley [EMAIL PROTECTED]
 Organization: Centre for Injury Studies
 Reply-To: [EMAIL PROTECTED]
 Date: Tue, 17 Jul 2001 12:53:57 +0930
 To: Brad Wright [EMAIL PROTECTED], PHP General List
 [EMAIL PROTECTED]
 Subject: Re: [PHP] Whats wrong with this code?
 
 On Tue, 17 Jul 2001 12:37, Brad Wright wrote:
 From: Rasmus Lerdorf [EMAIL PROTECTED]
 Date: Mon, 16 Jul 2001 19:56:29 -0700 (PDT)
 To: Brad Wright [EMAIL PROTECTED]
 Cc: PHP General List [EMAIL PROTECTED]
 Subject: Re: [PHP] Whats wrong with this code?
 
 Hi all, Im getting mighty frustrated with this peice of code. It
 checks the first condition no probs, but the second IF statement
 doesnt work. So it will stop if it finds a du[plicate login, but
 cannot find duplicate passwords. the $num_rows2 variable always gets
 the value '0' even when there is an existing password the same as
 the new user-entered value.
 
 $result = mysql_query(SELECT * FROM  Login_TB where
 Login='$Login',$db) or die (ouch);
 
 $num_rows = mysql_num_rows($result);
 
 $query2 = select * FROM Team_Login_TB where Pass =
 password('$Pass'); $result2 = mysql_query($query2,$db) or die
 (ouch2);
 $num_rows2 = mysql_num_rows($result2);
 
 Your second query must not be returning any rows.  Print out $query2
 and paste the string you see into the command line mysql tool and
 execute the query.  I bet it will return 0 rows.
 
 -Rasmus
 
 Rasmus,
 you are dead right, it is returning 0 rows. I checked that before
 submiytting the original post. Sorry, i should have mentioned it. I
 guess the question is, why is it returning no rows?
 
 This might be too obvious, but are you looking in the correct table? Your
 second query searches a different table from the first? Alternatively,
 you might be getting something you don't expect in $Pass.
 
 
 -- 
 David Robley  Techno-JoaT, Web Maintainer, Mail List Admin, etc
 CENTRE FOR INJURY STUDIES  Flinders University, SOUTH AUSTRALIA
 
 1200 bps used to seem so fast
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Whats wrong with this code?

2001-07-16 Thread Brad Wright

The only data in the table (Login_TB) is one row:
Login = a, and Pass= password('a').



 From: Rasmus Lerdorf [EMAIL PROTECTED]
 Date: Mon, 16 Jul 2001 20:24:44 -0700 (PDT)
 To: Brad Wright [EMAIL PROTECTED]
 Cc: PHP General List [EMAIL PROTECTED]
 Subject: Re: [PHP] Whats wrong with this code?
 
 Rasmus,
 you are dead right, it is returning 0 rows. I checked that before
 submiytting the original post. Sorry, i should have mentioned it. I guess
 the question is, why is it returning no rows?
 
 Uh, that is something we can't answer without having access to your actual
 data.
 
 -Rasmus
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]