php-general Digest 26 Dec 2002 10:42:56 -0000 Issue 1785

Topics (messages 129328 through 129346):

Re: How To Get Last Item Of An Array?
        129328 by: John W. Holmes
        129329 by: Jason Wong
        129330 by: Leon Mergen

How to display field after MySQL join.
        129331 by: Stephen of Blank Canvas
        129345 by: Jason Wong
        129346 by: Sean Burlington

Problem with compilation from CVS
        129332 by: Bc. Radek Krejča
        129333 by: Johannes Schlueter
        129334 by: Bc. Radek Krejča

Formatting text output
        129335 by: menezesd
        129336 by: John W. Holmes
        129338 by: Justin French

Insert Record (php.ini)
        129337 by: Edson Waite
        129339 by: John W. Holmes
        129341 by: Edson Waite
        129342 by: Javier

Re: MySQL
        129340 by: Mike Mannakee

UltraTemplate's documentation
        129343 by: Javier

Apache
        129344 by: Mantas Kriauciunas

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 ---
> I have an multi-dimensional array called $cat_data, which is info
> extracted
> from a MySQL DB. I want to retrieve the very last item of that array.
How
> would I do that? I know the first item can be retrieved by simply
asking
> for
> $cat_data[0][0], which contains an id number. But I can't figure out
how
> to
> get the last item in that same array -- $cat_data[x][0] where x is the
> last
> item in the array.

Kind of begs the question of why can't you just select what you need
with the proper query, instead of loading everything into an array...

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/


--- End Message ---
--- Begin Message ---
On Thursday 26 December 2002 03:34, Chris Wesley wrote:
> On Wed, 25 Dec 2002, @ Nilaab wrote:
> > I have an multi-dimensional array called $cat_data, which is info
> > extracted from a MySQL DB. I want to retrieve the very last item of that
> > array. How would I do that? I know the first item can be retrieved by
> > simply asking for $cat_data[0][0], which contains an id number. But I
> > can't figure out how to get the last item in that same array --
> > $cat_data[x][0] where x is the last item in the array.
>
> Naturally, the index of last item of an array is one less than the total
> number of elements in the array.
>
> $num_elements = count( $cat_data );
> $last_element = $cat_data[$num_elements-1][0];
> // 0 being what you were seeking

Or, if you don't need to keep $cat_data intact, you can use array_pop().

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

/*
When it is not necessary to make a decision, it is necessary not to
make a decision.
*/

--- End Message ---
--- Begin Message ---
"John W. Holmes" <[EMAIL PROTECTED]> schreef in bericht
000401c2ac54$142032c0$7c02a8c0@coconut">news:000401c2ac54$142032c0$7c02a8c0@coconut...
> Kind of begs the question of why can't you just select what you need
> with the proper query, instead of loading everything into an array...

Yeah, just add limit 0,1 desc to the query


--- End Message ---
--- Begin Message ---
Hi Everyone,
 
I'm trying to display the content of two mysql tables on a single page,
I have successfully joined them with the following statement.
 
$query = "SELECT serv.*, cat.* FROM site_services AS serv,
site_servicescat AS cat WHERE serv.servicescat_id = cat.servicescat_id
AND serv.theme_id = $DomainTheme AND serv.status = 1 ORDER BY RAND()
LIMIT 3";

This works great but my problem is I have a field in each table called
"title", if I use the normal function of $row[title] I get field from
the "site_services" table but I cannot work out how to get the
"site_servicescat" title field.  I have tried $row[cat.title] but all I
get is errors. 
 
Any help would be really appreciated as I think it's just me missing
something basic.
 
Thanks
 
Stephen
--- End Message ---
--- Begin Message ---
On Thursday 26 December 2002 07:25, Stephen of Blank Canvas wrote:
> Hi Everyone,
>
> I'm trying to display the content of two mysql tables on a single page,
> I have successfully joined them with the following statement.
>
> $query = "SELECT serv.*, cat.* FROM site_services AS serv,
> site_servicescat AS cat WHERE serv.servicescat_id = cat.servicescat_id
> AND serv.theme_id = $DomainTheme AND serv.status = 1 ORDER BY RAND()
> LIMIT 3";
>
> This works great but my problem is I have a field in each table called
> "title", if I use the normal function of $row[title] I get field from
> the "site_services" table but I cannot work out how to get the
> "site_servicescat" title field.  I have tried $row[cat.title] but all I
> get is errors.
>
> Any help would be really appreciated as I think it's just me missing
> something basic.

print_r($row) to see what you have.

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

/*
disbar, n:
        As distinguished from some other bar.
*/

--- End Message ---
--- Begin Message ---
Stephen of Blank Canvas wrote:
Hi Everyone,
I'm trying to display the content of two mysql tables on a single page,
I have successfully joined them with the following statement.
$query = "SELECT serv.*, cat.* FROM site_services AS serv,
site_servicescat AS cat WHERE serv.servicescat_id = cat.servicescat_id
AND serv.theme_id = $DomainTheme AND serv.status = 1 ORDER BY RAND()
LIMIT 3";
you can do

select name.cat as cname, name.serv as sname

which would give $row['cname'] and $row['sname']

or you could use the numeric indexes ($row[0], $row[1] etc)

or use print_r($row) to see the array contents in detail

This works great but my problem is I have a field in each table called
"title", if I use the normal function of $row[title] I get field from
the "site_services" table but I cannot work out how to get the
"site_servicescat" title field. I have tried $row[cat.title] but all I
get is errors. Any help would be really appreciated as I think it's just me missing
something basic.
Thanks
Stephen


--- End Message ---
--- Begin Message ---
Hello,
I try compile PHP from CVS. I download source, configure it, compile
it and install it. All ok, but after installation I got this:

Fatal error: main() [function.main]: Failed opening required 
'./libraries/grab_globals.lib.php' (include_path='.:/usr/local/lib/php') in 
/home/starnet.cz/dbadmin3/index.php on line 8

Where is problem, what I made bad?

Thanks
Radek


--- End Message ---
--- Begin Message ---
On Thursday 26 December 2002 00:57, Bc. Radek Krejča wrote:
> Fatal error: main() [function.main]: Failed opening required
> './libraries/grab_globals.lib.php' (include_path='.:/usr/local/lib/php') in
> /home/starnet.cz/dbadmin3/index.php on line 8
>
> Where is problem, what I made bad?

Hi,

are you sure you have all PHP-Files your PHP-Project needs? The error message 
tells you that your script trys to load ./libraries/grab_globals.lib.php at 
index.php, line 8, check wether the grab_globals.lib.php is reachable...

johannes
--- End Message ---
--- Begin Message ---
Hello,

  yes, I am. Because if I compile PHP from source.tar.gz (version
  4.2.3), it works. But I am not sure with version of PHP from CVS. I
  try

  cvs -d :pserver:[EMAIL PROTECTED]:/repository co -r PHP_4_2_3 php4

  but answer is only cvs [server aborted]: no such tag PHP_4_2_3.

  Command
  cvs -d :pserver:[EMAIL PROTECTED]:/repository co -r PHP_4_2_2 php4
  works perfectly. I don't know, what I make bad.

  Thanks Radek

JS> On Thursday 26 December 2002 00:57, Bc. Radek Krejča wrote:
>> Fatal error: main() [function.main]: Failed opening required
>> './libraries/grab_globals.lib.php' (include_path='.:/usr/local/lib/php') in
>> /home/starnet.cz/dbadmin3/index.php on line 8
>>
>> Where is problem, what I made bad?

JS> Hi,

JS> are you sure you have all PHP-Files your PHP-Project needs? The error message 
JS> tells you that your script trys to load ./libraries/grab_globals.lib.php at 
JS> index.php, line 8, check wether the grab_globals.lib.php is reachable...

JS> johannes


--- End Message ---
--- Begin Message ---
Hello friends.

I work for a school where we need to put the class results on to our web, one for 
every class. We enter the marks in the database and this should be displayed in a 
particular varying format as follows(an example) :

Grade A Pass :
4554 7687 9834 2354 7671

Grade B Pass :
0045 7612 2297

Failed :
3104 6509 0286 8765 2229 0978

How can I put this in Mysql and get the same test formatting out? If the grade types 
where standard and limited, it was okay. But the grades types can increase or 
decrease. How can I maintain the same formatting as what I input?

Thanks very much
Denis
--- End Message ---
--- Begin Message ---
> I work for a school where we need to put the class results on to our
web,
> one for every class. We enter the marks in the database and this
should be
> displayed in a particular varying format as follows(an example) :
> 
> Grade A Pass :
> 4554 7687 9834 2354 7671
> 
> Grade B Pass :
> 0045 7612 2297
> 
> Failed :
> 3104 6509 0286 8765 2229 0978
> 
> How can I put this in Mysql and get the same test formatting out? If
the
> grade types where standard and limited, it was okay. But the grades
types
> can increase or decrease. How can I maintain the same formatting as
what I
> input?

How are you getting it into the database? MySQL isn't going to change
the formatting of that text at all. Now, if you were to display it in an
HTML page, it won't look the same. HTML does not recognize newlines,
only <br> tags. Here is where the nl2br() function comes in handy, or
<pre> tags. 

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/


--- End Message ---
--- Begin Message ---
What does the database table(s) look like?

I don't understand what '0045' and '2354' are -- are they student no's?

Better questions get better answers :)

Justin





on 26/12/02 12:03 PM, menezesd ([EMAIL PROTECTED]) wrote:

> Hello friends.
> 
> I work for a school where we need to put the class results on to our web, one
> for every class. We enter the marks in the database and this should be
> displayed in a particular varying format as follows(an example) :
> 
> Grade A Pass :
> 4554 7687 9834 2354 7671
> 
> Grade B Pass :
> 0045 7612 2297
> 
> Failed :
> 3104 6509 0286 8765 2229 0978
> 
> How can I put this in Mysql and get the same test formatting out? If the grade
> types where standard and limited, it was okay. But the grades types can
> increase or decrease. How can I maintain the same formatting as what I input?
> 
> Thanks very much
> Denis

--- End Message ---
--- Begin Message ---
Hi all,

Hope everyone had a Merry Christmas.

 I am trying to create a form to insert records into a MySQL db what setting
should I be looking at in the php.ini? My page seems to work and goes to the
next page correctly without errors, but does not enter any information in
the database.

Thanks in Advance,
Edson Waite III



--- End Message ---
--- Begin Message ---
>  I am trying to create a form to insert records into a MySQL db what
> setting
> should I be looking at in the php.ini? My page seems to work and goes
to
> the
> next page correctly without errors, but does not enter any information
in
> the database.

Probably register_globals, if I had to guess. Otherwise, show your code
so we can see what's going on. 

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/


--- End Message ---
--- Begin Message ---
I checked and register_globals is ON, I am new to php and I am building on a
tutorial from a book. below is the code any help would be appeciated.

Thank you,
Ed Waite

<?php
phpinfo();
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
$theNotDefinedValue = "")
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" :
"NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue :
$theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
  $editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}

if ((isset($HTTP_POST_VARS["MM_insert"])) && ($HTTP_POST_VARS["MM_insert"]
== "Contribution")) {
  $insertSQL = sprintf("INSERT INTO stories (firstName, lastName, address1,
address2, city, `state`, country, postCode, telephone, email, title, story)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($HTTP_POST_VARS['firstName'],
"text"),
                       GetSQLValueString($HTTP_POST_VARS['lastName'],
"text"),
                       GetSQLValueString($HTTP_POST_VARS['address1'],
"text"),
                       GetSQLValueString($HTTP_POST_VARS['address2'],
"text"),
                       GetSQLValueString($HTTP_POST_VARS['city'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['state'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['country'],
"text"),
                       GetSQLValueString($HTTP_POST_VARS['postCode'],
"text"),
                       GetSQLValueString($HTTP_POST_VARS['telephone'],
"text"),
                       GetSQLValueString($HTTP_POST_VARS['email'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['title'], "text"),
                       GetSQLValueString($HTTP_POST_VARS['story'], "text"));

  mysql_select_db($database_afm, $afm);
  $Result1 = mysql_query($insertSQL, $afm) or die(mysql_error());

  $insertGoTo = "process_story.php";
  if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>


"John W. Holmes" <[EMAIL PROTECTED]> wrote in message
000401c2ac90$8a2f77f0$7c02a8c0@coconut">news:000401c2ac90$8a2f77f0$7c02a8c0@coconut...
> >  I am trying to create a form to insert records into a MySQL db what
> > setting
> > should I be looking at in the php.ini? My page seems to work and goes
> to
> > the
> > next page correctly without errors, but does not enter any information
> in
> > the database.
>
> Probably register_globals, if I had to guess. Otherwise, show your code
> so we can see what's going on.
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>


--- End Message ---
--- Begin Message ---
There are single quotes missing before %s -> '%s'

>   $insertSQL = sprintf("INSERT INTO stories (firstName, lastName,
>   address1, 
> address2, city, `state`, country, postCode, telephone, email, title,
> story) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
>                        GetSQLValueString($HTTP_POST_VARS['firstName'],


-- 
*** s2r - public key: (http://leeloo.mine.nu/s2r-gmx.sig)
--- End Message ---
--- Begin Message ---
Perhaps setting the ini file socket info is bypassing php using the tcp port
directly.  It should be going 'through' tcp/ip to get at the port mysql is
listening to and they talk through there.  I'm on a windows box and have
limited experience with unix implementations, but on the one linux box I did
get up and running I don't think I had set the php.ini to any sockets.  Try
commenting out the line.

If you can get the sql error number and message it will also help you
determine what's up.

Mike


<[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I'm having some problems with MySQL.  PHP just isn't working with it.
> I'm running Apache 1.3.27 with PHP 4.2.3 and MySQL 3.23.49 on OpenBSD 3.2.
> Apache and PHP were compiled with source (PHP was configured with
> --with-mysql and --with-apxs), and MySQL was installed from a package.
> I can connect to MySQL via the command-line interface, but not via PHP.
> phpBB always reports "cannot connect to database".  I've checked the
> permissions and everything, and it all should work.
> I've also set the mysql socket in php.ini to /var/run/mysql/mysql.sock
> because that's where it is.
>
> Thanks,
> Parry60


--- End Message ---
--- Begin Message ---
Hi!
Has anybody got documentation for UltraTemplate? I read the examples on 
their website but I didn't understand it very well.

Any doc. would be apreciated. :)


-- 
*** s2r - public key: (http://leeloo.mine.nu/s2r-gmx.sig)
--- End Message ---
--- Begin Message ---
Hey!
I'm using FreeBSD 4.5 as my server and I have loaded Apache 1.3.2 and
PHP 4.x . hare goes the question, sorry it isn't about php but still
maybe you can help me. When I type Http://www.example.com/~user the page
says that it doesn't exist.. But when I type in
Http://www.example.com/~user/ then it works. Well when I had PHPTriad
loaded on my windows I didn't have any problems. Why now it isn't
working without / ??
Thanks!
--- End Message ---

Reply via email to