RE: Still struggeling with my first script...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



twistednetadmin <mailto:twistednetadmin@xxxxxxxxx>
    on Friday, October 14, 2005 5:15 PM said:

> All: Sorry..... I forgot to write what's wrong....stupid me...

No problem. You'll get used to it. (I don't mean you'll get used to
being stupid! I mean you'll get used to including all the relevant
info!)

> It's just rather annoying that all the tutorials I
> have tried seems to fail. How can I learn when I'm apparently given
> the wrong information.

The best way to learn is start with the very basics (which according to
this one example you are not). First try to simply connect to a database
and execute a simple query.

> -----------------------------------
> Guildlogin.php
> -----------------------------------
> This should create a session variable for the authentication, but it
> fails at some point.

The way to debug this is by adding simple echo statements in each block
of code. This will tell you what path the code is taking while
processing.

<?php

if (this)
{
 echo "1";
}
else
{
 echo "2";

 if(this and that and the other)
 {
  echo "3";
 }
}

?>

> I have checked the sessiondata on my testserver,
> and that shows blank.

Does every page that uses the $_SESSION variable have session_start() at
beginning?

> I don't get any sql
> errors, so I don't think that is the problem. But then again....it is
> my first script, and I could offcourse be wrong. I'm not sure where I
> should put the echo $sql; to check the query. Since the Guildlogin.php
> sends me directly to the error page at the end of execution.

You should place the echo statement immediately before the SQL query is
executed. (See below.)

> --------------------
> Code for Guildlogin.php:
> ----------------------
> <?php
> include ("connections/HOoStest.php");
> 
> 
> 
> session_start();
> if (@$_GET['guildaction'] == "login");
> {
> 
>         $sql = "SELECT guilduser_name FROM guildlogin
>                 WHERE guilduser_name='$_POST[guilduser_name]'";

$_POST[guilduser_name] should look like {$_POST['guilduser_name']}.

When an array is within a string it needs to be wrapped in curly braces.
You should also always quote all your keys with ' so that the parser
doesn't get confused with constants.

Put the echo statement immediately before the following line.

>         $result = mysql_query($sql) or die("Couldn't execute query.");


That's all I have time for right now.


HTH,
Chris.

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux