Page 2 of 2
Posted: Thu Mar 23, 2006 8:15 pm
by RobertGonzalez
OK, remove this portion of code:
Code: Select all
<?php
//if there's exactly one result, the user is validated. Otherwise, he's invalid
if(1 == mysql_num_rows($result)) {
echo 'validated';
}
else {
echo 'not valid';
}
?>
And replace it with:
Code: Select all
<?php
echo mysql_num_rows($result);
?>
Without the opening and closing PHP tags of course. See what that does.
Posted: Thu Mar 23, 2006 8:31 pm
by Cheeseboy
ok where getting there i got this:
Code: Select all
?php session_start(); ?> Ok, we are about to start: 07-18-2004 12:06 PM.
Fatal error: Call to undefined function: mysql_connect() in /var/www/Esgames4uweb/validate.php on line 19
I have to ask you guys about every error because im not very experienced with php
Posted: Thu Mar 23, 2006 8:34 pm
by Benjamin
Check your apache config file to ensure that the mysql module is enabled. You may just have to uncomment a line.
Posted: Thu Mar 23, 2006 10:22 pm
by RobertGonzalez
This could very well be a php.ini extension problem as well. Check to make sure the mysql (or mysqli) extension is enabled in the php.ini file.
Posted: Fri Mar 24, 2006 5:51 am
by Cheeseboy
yes, it is enabled and how would i uncomment the line? Should i have mysql trace mode on as well?
Posted: Fri Mar 24, 2006 7:48 am
by RobertGonzalez
That's really weird. If the mysql extensionis enabled in your php.ini then you shouldn't be getting the error you got. I will have to think about this one for a bit.
Posted: Fri Mar 24, 2006 9:25 am
by Benjamin
Posted: Fri Mar 24, 2006 9:47 am
by RobertGonzalez
Excellent resource. I had no idea that mysql support did not come with RedHat. That is very interesting.
Posted: Fri Mar 24, 2006 3:55 pm
by Cheeseboy
What line exactly is that mysql extension at anyways? I think i mistaked another extension.

and cant find it.
Posted: Fri Mar 24, 2006 4:54 pm
by Cheeseboy
feyd | Please use Code: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
THis is what my current code im trying to get to work looks like:
Code: Select all
<?php
session_start();
?>
<html>
<head>
<title>validate.php</title>
</head>
<body>
Ok, we are about to start: <?php echo date("m-d-Y g:i A"); ?>.
<?php
if (isset($_POST))
{
$user_name = $_POST['user_name'];
$password = $_POST['password'];
$db_user = 'mysql_username';
$db_pass = 'mysql_password';
//connect to the DB and select the "dictator" database
$connection = mysql_connect('localhost', $db_user, $db_pass) or
die(mysql_error());
mysql_select_db('Esgames4ulogin') or die(mysql_error());
//set up the query
$query = "SELECT * FROM users
WHERE user_name='$user_name' AND password='$password'";
// Test output of something
echo $query . "<br />\n";
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making
query: ' .mysql_error());
echo mysql_num_rows($result);
}
else
{
echo 'There was nothing posted...';
}
?>
OK, finishing up: <?php echo date("m-d-Y g:i A"); ?>.
</body>
</html>
feyd | Please use Code: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Fri Mar 24, 2006 4:59 pm
by feyd
Cheeseboy wrote:Code: Select all
$query = "SELECT * FROM users
WHERE user_name='$user_name' AND password='$password'";
SQL Injection alert. Read through the security forum posts to find out how to fix that.
Posted: Fri Mar 24, 2006 5:42 pm
by Cheeseboy
How are the variables $user_name and $password defined? Are they coming through post, cookies, get or sessions?
Posted: Fri Mar 24, 2006 5:48 pm
by feyd
it's your code, look at it. Your answer is right above the quoted code.
Posted: Sat Mar 25, 2006 9:35 pm
by Cheeseboy
I found this:
Code:
Code: Select all
Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
;
; If you wish to have an extension loaded automatically, use the following
; syntax:
;
; extension=modulename.extension
;
; For example, on Windows:
;
; extension=msql.dll
;
; ... or under UNIX:
;
; extension=msql.so
;
; Note that it should be the name of the module only; no directory information
; needs to go here. Specify the location of the extension with the
; extension_dir directive above.
;
; Load the MySQL module by default. Comment this out if you don't use MySQL.
extension=mysql.so
; Load the gettext extension by default. Comment this out if you don't have the
; gettext shared library installed.
extension=gettext.so
Heres my extensions:
Code: Select all
;Windows Extensions
;Note that MySQL and ODBC support is now built in, so no dll is needed for it.
;;extension=php_mbstring.dll
;extension=php_mbstring.dll
;extension=php_bz2.dll
;extension=php_cpdf.dll
;extension=php_crack.dll
;extension=php_curl.dll
;extension=php_db.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_dbx.dll
;extension=php_domxml.dll
;extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_filepro.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_hyperwave.dll
;extension=php_iconv.dll
;extension=php_ifx.dll
;extension=php_iisfunc.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_java.dll
;extension=php_ldap.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_msql.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_oracle.dll
;extension=php_pdf.dll
;extension=php_pgsql.dll
;extension=php_printer.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_sockets.dll
;extension=php_sybase_ct.dll
;extension=php_w32api.dll
;extension=php_xmlrpc.dll
;extension=php_xslt.dll
;extension=php_yaz.dll
;extension=php_zip.dll
Heres some more info that show my extensions and that i dont have the extension=php_mysql