A few Problems

Problems with the Linux version of XAMPP, questions, comments, and anything related.

A few Problems

Postby ddnut » 15. February 2010 08:18

Ok Ill start with one problem I have.
When I run the built in security
./lampp security

it will show mysql on the xampp status page that sql is DEACTIVATED

If I dont bother doing this after install it shows it as active.
is there a reason for this or should I be worried that I cant connect as I can look it up and it is running even with it labled as deactivated.(yes I can log in under phpmyadmin page)


Problem :2
Im looking to do a simple form in a 2 parts
file1 confg.php
file2 index.php

File 1 confg.php body holds

Code: Select all
<? //=====Rage scripting=====//  //=====For MySQL Datatbase=====//

   $DBHost = "localhost";  // localhost or your IP
   $DBUser = "root";  // Database user
   $DBPassword = "root";  // Database password
   $DBName = "dbo";  // Database name
   
?>   
   

this is used for accsess to mysql for the index.php file

File 2 index.php body holds

Code: Select all
<? //=====Rage scripting=====//  //=====For MySQL Database=====//
   include "config.php";
   
   $Data = '<form action=index.php method=post>
    Login: 
   <br><input type=text name=login><br><br>
    Password:
   <br><input type=password name=passwd><br><br>
    Repeat password:
   <br><input type=password name=repasswd><br><br>
   Email:
   <br><input type=text name=email><br><br>
   <input type=submit name=submit value="Registration">
   </form>';
      
   if (isset($_POST['login']))
      {
         $Link = MySQL_Connect($DBHost, $DBUser, $DBPassword) or die ("Can't connect to MySQL");
         MySQL_Select_Db($DBName, $Link) or die ("Database ".$DBName." do not exists.");
         
         $Login = $_POST['login'];
         $Pass = $_POST['passwd'];
         $Repass = $_POST['repasswd'];
         $Email = $_POST['email'];
         
         $Login = StrToLower(Trim($Login));
         $Pass = StrToLower(Trim($Pass));
         $Repass = StrToLower(Trim($Repass));
         $Email = Trim($Email);
   
      if (empty($Login) || empty($Pass) || empty($Repass) || empty($Email))
         {
             echo "All fields is empty.";
         }
      
      elseif (ereg("[^0-9a-zA-Z_-]", $Login, $Txt))
         {
            echo "Login have a incorrect format.";
         }
         
      elseif (ereg("[^0-9a-zA-Z_-]", $Pass, $Txt))
         {
            echo "Password have a incorrect format.";   
         }
      
      elseif (ereg("[^0-9a-zA-Z_-]", $Repass, $Txt))
         {
            echo "Repeat password have a incorrect format.";   
         }
      elseif (StrPos('\'', $Email))
         {
            echo "Email have a incorrect format.";   
         }   
      else
         {
            $Result = MySQL_Query("SELECT name FROM users WHERE name='$Login'") or ("Can't execute query.");
            
      if (MySQL_Num_Rows($Result))
         {
            echo "Account <b>".$Login."</b> is exists";
         }
      
      elseif ((StrLen($Login) < 4) or (StrLen($Login) > 10))
      
         {
            echo "Login must have more 4 and not more 10 symbols.";
         }
         
      elseif ((StrLen($Pass) < 4) or (StrLen($Pass) > 10))
      
         {
            echo "Password must have more 4 and not more 10 symbols.";
         }
         
      elseif ((StrLen($Repass) < 4) or (StrLen($Repass) > 10))
         {
            echo "Repeat password must have more 4 and not more 10 symbols.";
         }
         
      elseif ((StrLen($Email) < 4) or (StrLen($Email) > 25))
         {
            echo "Email must have more 4 and not more 25 symbols.";
         }
      
      elseif ($Pass != $Repass)
         {
            echo "Password mismatch.";
         }      
      else
         {
            $Salt = $Login.$Pass;
            $Salt = md5($Salt);
            $Salt = "0x".$Salt;
            MySQL_Query("call adduser('$Login', $Salt, '0', '0', '0', '0', '$Email', '0', '0', '0', '0', '0', '0', '0', '', '', $Salt)") or die ("Can't execute query.");
            echo "Account <b>".$Login."</b> has been registered.";
         }      
      }   
   }
   
   echo $Data;   
   
?>


my problem here is I get the following error Deprecated: Function ereg() is deprecated in /opt/lampp/htdocs/register/index.php on line 36

Deprecated: Function ereg() is deprecated in /opt/lampp/htdocs/register/index.php on line 41

Deprecated: Function ereg() is deprecated in /opt/lampp/htdocs/register/index.php on line 46
Can't execute query.

I did put error_reporting = E_ALL & ~E_DEPRECATED

Can anyone see where I am messing this up? Thank you so vary much in advance
ddnut
 
Posts: 7
Joined: 15. February 2010 07:14

Re: A few Problems

Postby Wiedmann » 15. February 2010 09:32

When I run the built in security
./lampp security

it will show mysql on the xampp status page that sql is DEACTIVATED

I guess that's a bug in the status page. And if you can work with phpMyAmdin: Don't be worry.


I did put error_reporting = E_ALL & ~E_DEPRECATED

So your problem with "Function ereg() is deprecated" is solved?
But I think it's better the replace ereg().

Code: Select all
... or die ("Can't execute query."); 

Can't execute query.

It's always better to use mysql_error(), instead of printing a message which does not have any info about the problem.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: A few Problems

Postby ddnut » 15. February 2010 14:28

Sorry I forgot to add that after I turned the error like that I get no change and errors still shows.Vary sorry to make you ask when I should have said(was a late night :oops: )

I was wondering is there a trace to the SQL like for say the CD Demo(on phpmyadmin) cause I noticed it had an error till I patched the user and pass in the PHP file maybe the status page needs a little help as the CD demo did?(If not this error dont bother me much as its all local for a game server for my household).

I redid as you said and it shows the error to the database
Code: Select all
<? //=====Script by trash=====//  //=====For MySQL Database=====//
   include "config.php";
   
   $Data = '<form action=index.php method=post>
    Login: 
   <br><input type=text name=login><br><br>
    Password:
   <br><input type=password name=passwd><br><br>
    Repeat password:
   <br><input type=password name=repasswd><br><br>
   Email:
   <br><input type=text name=email><br><br>
   <input type=submit name=submit value="Registration">
   </form>';
      
   if (isset($_POST['login']))
      {
         $Link = MySQL_Connect($DBHost, $DBUser, $DBPassword) MySQL_Error($Link);
         MySQL_Select_Db($DBName, $Link) MySQL_Error();
         
         $Login = $_POST['login'];
         $Pass = $_POST['passwd'];
         $Repass = $_POST['repasswd'];
         $Email = $_POST['email'];
         
         $Login = StrToLower(Trim($Login));
         $Pass = StrToLower(Trim($Pass));
         $Repass = StrToLower(Trim($Repass));
         $Email = Trim($Email);
   
      if (empty($Login) || empty($Pass) || empty($Repass) || empty($Email))
         {
             echo "All fields is empty.";
         }
      
      elseif (ereg("[^0-9a-zA-Z_-]", $Login, $Txt))
         {
            echo "Login have a incorrect format.";
         }
         
      elseif (ereg("[^0-9a-zA-Z_-]", $Pass, $Txt))
         {
            echo "Password have a incorrect format.";   
         }
      
      elseif (ereg("[^0-9a-zA-Z_-]", $Repass, $Txt))
         {
            echo "Repeat password have a incorrect format.";   
         }
      elseif (StrPos('\'', $Email))
         {
            echo "Email have a incorrect format.";   
         }   
      else
         {
            $Result = MySQL_Query("SELECT name FROM users WHERE name='$Login'") MySQL_Error();
            
      if (MySQL_Num_Rows($Result))
         {
            echo "Account <b>".$Login."</b> is exists";
         }
      
      elseif ((StrLen($Login) < 4) or (StrLen($Login) > 10))
      
         {
            echo "Login must have more 4 and not more 10 symbols.";
         }
         
      elseif ((StrLen($Pass) < 4) or (StrLen($Pass) > 10))
      
         {
            echo "Password must have more 4 and not more 10 symbols.";
         }
         
      elseif ((StrLen($Repass) < 4) or (StrLen($Repass) > 10))
         {
            echo "Repeat password must have more 4 and not more 10 symbols.";
         }
         
      elseif ((StrLen($Email) < 4) or (StrLen($Email) > 25))
         {
            echo "Email must have more 4 and not more 25 symbols.";
         }
      
      elseif ($Pass != $Repass)
         {
            echo "Password mismatch.";
         }      
      else
         {
            $Salt = $Login.$Pass;
            $Salt = md5($Salt);
            $Salt = "0x".$Salt;
            MySQL_Query("call adduser('$Login', $Salt, '0', '0', '0', '0', '$Email', '0', '0', '0', '0', '0', '0', '0', '', '', $Salt)") MySQL_Error();
            echo "Account <b>".$Login."</b> has been registered.";
         }      
      }   
   }
   
   echo $Data;   
   
?>


Error for this now shows Parse error: syntax error, unexpected T_STRING in /opt/lampp/htdocs/register/index.php on line 18
This leads to my config.php (mysql info for index.php) so I guess im off to look at my database layout. I also noticed its like phpmyadmin can hang somewhat whit the new changes maybe I missed adding something or format?

Thank you vary much im new to mysql databases and newer to php(have done some in the past but not alot)
ddnut
 
Posts: 7
Joined: 15. February 2010 07:14

Re: A few Problems

Postby ddnut » 15. February 2010 14:39

Oh not sure if this is of use to you but I can post layout structure of my database if needed.Thanks again I feel like im getting somewhere now :D
ddnut
 
Posts: 7
Joined: 15. February 2010 07:14

Re: A few Problems

Postby Wiedmann » 15. February 2010 15:23

Code: Select all
$Link = MySQL_Connect($DBHost, $DBUser, $DBPassword) MySQL_Error($Link); 

Parse error: syntax error, unexpected T_STRING in /opt/lampp/htdocs/register/index.php on line 18

mysql_error() is returning a string, which you must print to the browser:
Code: Select all
$Link = mysql_connect($DBHost, $DBUser, $DBPassword) or die('Could not connect: ' . mysql_error()); 


BTW:
Code: Select all
<? 

Better use:
Code: Select all
<?php
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: A few Problems

Postby ddnut » 16. February 2010 13:56

I must be new never seen the PHP missing.

K I altered it to the following
Code: Select all
<?php //=====?Rage Scripting=====//  //=====For MySQL Database=====//
   include "config.php";
   
   $Data = '<form action=index.php method=post>
    Login: 
   <br><input type=text name=login><br><br>
    Password:
   <br><input type=password name=passwd><br><br>
    Repeat password:
   <br><input type=password name=repasswd><br><br>
   Email:
   <br><input type=text name=email><br><br>
   <input type=submit name=submit value="Registration">
   </form>';
      
   if (isset($_POST['login']))
      {
         $Link = MySQL_Connect($DBHost, $DBUser, $DBPassword)  or die ('Could not connect: ' . mysql_error())
         MySQL_Select_Db($DBName, $Link) MySQL_Error($Link);
         
         $Login = $_POST['login'];
         $Pass = $_POST['passwd'];
         $Repass = $_POST['repasswd'];
         $Email = $_POST['email'];
         
         $Login = StrToLower(Trim($Login));
         $Pass = StrToLower(Trim($Pass));
         $Repass = StrToLower(Trim($Repass));
         $Email = Trim($Email);
   
      if (empty($Login) || empty($Pass) || empty($Repass) || empty($Email))
         {
             echo "All fields is empty.";
         }
      
      elseif (ereg("[^0-9a-zA-Z_-]", $Login, $Txt))
         {
            echo "Login have a incorrect format.";
         }
         
      elseif (ereg("[^0-9a-zA-Z_-]", $Pass, $Txt))
         {
            echo "Password have a incorrect format.";   
         }
      
      elseif (ereg("[^0-9a-zA-Z_-]", $Repass, $Txt))
         {
            echo "Repeat password have a incorrect format.";   
         }
      elseif (StrPos('\'', $Email))
         {
            echo "Email have a incorrect format.";   
         }   
      else
         {
            $Result = MySQL_Query("SELECT name FROM users WHERE name='$Login'") MySQL_Error($Link);
            
      if (MySQL_Num_Rows($Result))
         {
            echo "Account <b>".$Login."</b> is exists";
         }
      
      elseif ((StrLen($Login) < 4) or (StrLen($Login) > 10))
      
         {
            echo "Login must have more 4 and not more 10 symbols.";
         }
         
      elseif ((StrLen($Pass) < 4) or (StrLen($Pass) > 10))
      
         {
            echo "Password must have more 4 and not more 10 symbols.";
         }
         
      elseif ((StrLen($Repass) < 4) or (StrLen($Repass) > 10))
         {
            echo "Repeat password must have more 4 and not more 10 symbols.";
         }
         
      elseif ((StrLen($Email) < 4) or (StrLen($Email) > 25))
         {
            echo "Email must have more 4 and not more 25 symbols.";
         }
      
      elseif ($Pass != $Repass)
         {
            echo "Password mismatch.";
         }      
      else
         {
            $Salt = $Login.$Pass;
            $Salt = md5($Salt);
            $Salt = "0x".$Salt;
            MySQL_Query("call adduser('$Login', $Salt, '0', '0', '0', '0', '$Email', '0', '0', '0', '0', '0', '0', '0', '', '', $Salt)") MySQL_Error($Link);
            echo "Account <b>".$Login."</b> has been registered.";
         }      
      }   
   }
   
   echo $Data;   
   
?>

something is still not right like it is not finding the confg.php file or something like that as it always leads to the mysql accsess info.Ill look at it some more has to be something small.

I fixed the error of the cd demo and now the mysql deactivated in the phpmyadmin it was that the php files needed accsess to mysql after I changed the password
ddnut
 
Posts: 7
Joined: 15. February 2010 07:14

Re: A few Problems

Postby ddnut » 16. February 2010 14:27

well messing around with a php error checker it looks to be the mysql_error($Link) or ($Link) thruout the script.Is this needed or any reason this is causing the error?
thanks again you been a huge help

and after I fix the errors this way I come up with a few more errors as if it will not sink with the database I have set up cause the errors are after the form was submitted
ddnut
 
Posts: 7
Joined: 15. February 2010 07:14

Re: A few Problems

Postby ddnut » 16. February 2010 14:51

Wiedmann wrote:
I did put error_reporting = E_ALL & ~E_DEPRECATED

So your problem with "Function ereg() is deprecated" is solved?
But I think it's better the replace ereg().

well I guess the errors from this are not fixed as I get 3 from this after I removed the sql_error or $Link lines

wow seams to be never ending problems
ddnut
 
Posts: 7
Joined: 15. February 2010 07:14

Re: A few Problems

Postby Wiedmann » 16. February 2010 15:57

and after I fix the errors this way

So how does the above script looks like now?
(the above script is still buggy. btw: which editor are you using?)

I come up with a few more errors a

Which errors.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: A few Problems

Postby ddnut » 16. February 2010 17:49

well the page wont come up till I edit it like this
Code: Select all
<?php //=====?Rage Scripting=====//  //=====For MySQL Database=====//
   include "config.php";
   
   $Data = '<form action=index.php method=post>
    Login: 
   <br><input type=text name=login><br><br>
    Password:
   <br><input type=password name=passwd><br><br>
    Repeat password:
   <br><input type=password name=repasswd><br><br>
   Email:
   <br><input type=text name=email><br><br>
   <input type=submit name=submit value="Registration">
   </form>';
      
   if (isset($_POST['login']))
      {
         $Link = MySQL_Connect($DBHost, $DBUser, $DBPassword);
         MySQL_Select_Db($DBName, $Link);
         
         $Login = $_POST['login'];
         $Pass = $_POST['passwd'];
         $Repass = $_POST['repasswd'];
         $Email = $_POST['email'];
         
         $Login = StrToLower(Trim($Login));
         $Pass = StrToLower(Trim($Pass));
         $Repass = StrToLower(Trim($Repass));
         $Email = Trim($Email);
   
      if (empty($Login) || empty($Pass) || empty($Repass) || empty($Email))
         {
             echo "All fields is empty.";
         }
      
      elseif (ereg("[^0-9a-zA-Z_-]", $Login, $Txt))
         {
            echo "Login have a incorrect format.";
         }
         
      elseif (ereg("[^0-9a-zA-Z_-]", $Pass, $Txt))
         {
            echo "Password have a incorrect format.";   
         }
      
      elseif (ereg("[^0-9a-zA-Z_-]", $Repass, $Txt))
         {
            echo "Repeat password have a incorrect format.";   
         }
      elseif (StrPos('\'', $Email))
         {
            echo "Email have a incorrect format.";   
         }   
      else
         {
            $Result = MySQL_Query("SELECT name FROM users WHERE name='$Login'");
            
      if (MySQL_Num_Rows($Result))
         {
            echo "Account <b>".$Login."</b> is exists";
         }
      
      elseif ((StrLen($Login) < 4) or (StrLen($Login) > 10))
      
         {
            echo "Login must have more 4 and not more 10 symbols.";
         }
         
      elseif ((StrLen($Pass) < 4) or (StrLen($Pass) > 10))
      
         {
            echo "Password must have more 4 and not more 10 symbols.";
         }
         
      elseif ((StrLen($Repass) < 4) or (StrLen($Repass) > 10))
         {
            echo "Repeat password must have more 4 and not more 10 symbols.";
         }
         
      elseif ((StrLen($Email) < 4) or (StrLen($Email) > 25))
         {
            echo "Email must have more 4 and not more 25 symbols.";
         }
      
      elseif ($Pass != $Repass)
         {
            echo "Password mismatch.";
         }      
      else
         {
            $Salt = $Login.$Pass;
            $Salt = md5($Salt);
            $Salt = "0x".$Salt;
            MySQL_Query("call adduser('$Login', $Salt, '0', '0', '0', '0', '$Email', '0', '0', '0', '0', '0', '0', '0', '', '', $Salt)");
            echo "Account <b>".$Login."</b> has been registered.";
         }      
      }   
   }
   
   echo $Data;   
   
?>


then the errors I get when I submit the page(as it sits above) I get errors:
Deprecated: Function ereg() is deprecated in /opt/lampp/htdocs/register/index.php on line 36

Deprecated: Function ereg() is deprecated in /opt/lampp/htdocs/register/index.php on line 41

Deprecated: Function ereg() is deprecated in /opt/lampp/htdocs/register/index.php on line 46
Account ddnut has been registered.
(then it shows the form here)

as you can see I hacked out some of what you asked me to try as well.this was needed or the page would not show what so ever

I use gedit or abiword as they are already in my fedora 12 install.And as you can see it says I registered an account but I look on phpmyadmin and under the database and I can see no records so it could not have registered
ddnut
 
Posts: 7
Joined: 15. February 2010 07:14


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 7 guests