Your _Name1 in your SELECT doesn't have a $ in front of it.

$_query = "select userName from users where userName = '$_Name1' ";
or
$_query = "select userName from users where userName = '".$_Name1."' ";

Also after you query your database you have to get the results from your
select.
$_result after $_result = mysql_query($_query) or   die(mysql_error());
will only hold false or true depending on the success of the query.

Use mysql_result or mysql_fetch_array to get your results.

Example:
$userName = mysql_reqult($result,0);

"Nik Alleyne" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi there
> I am having a problem querrying to my database.
> I wish to check to see if a username is listed in the database so that I
can
> authenticate that individual. However, when I try to echo my $_result i'm
> always getting 0 can someone please help. I think it should be either 1 or
> 0.
>
> These are my scripts.
>
> This is my login pagepage
> <?php
>     echo "<FORM name=_Form1 method=post action=test.php>";
>    echo "<TABLE border=1 width=300 height=300>";
>   echo "<tr>";
>    echo "<td valign=top>";
>     echo "<INPUT type=text value='' name=_Name1><br>";
>     echo "<INPUT type=text value='' name=_Name2><br>";
>     echo "<INPUT type=submit value='Submit' name=_submitButton>";
>     echo "<INPUT type=Reset value='Reset' name=_ResetButton><br>";
>    echo "</td valign=top>";
>      echo "</tr>";
>    echo "</TABLE>";
>  echo "</FORM>"
> ?>
>
> This is my script processor
> <?php
>     file://Script processor
>     mysql_connect("localhost", "nik", "playas") or
>      die("Could not connect to the server");
>
>  mysql_select_db("chronicleOnline") or
>   die("Could not connect to the database");
>
>  $_query = " select userName from users where userName='_Name1' ";
>
>  $_result = mysql_query($_query) or
>   die(mysql_error());
>
>  if ( $_result = 0 )
>   {
>     echo "$_result";
>   }
>  else
>   {
>    echo "$_result";
>   }
> ?>
>
> P.S. I have no problem putting the data into the database, just this
query.
>
> Thx
> Nik
>
>



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

Reply via email to