Page 1 of 1
Im new and i need help????
Posted: Tue Dec 30, 2014 12:34 pm
by treesnake1234
Hi all
I am currently going through some problems could anyone see if they could fix it?
I am working through the Project Battle tutorial aka Javascript/Ajax Building a MMORPG
I am having problems with the connect.php could someone look at it and see if they can see whats wrong?
connect.php
Code: Select all
<?php
$db = mysql_connect("localhost", "root", "pass") or die("Could not connect.");
if(!$db)
die("no db");
if(!mysql_select_db("battle",$db))
die("No database selected.");
if(!get_magic_quotes_gpc())
{
$_GET = array_map('mysql_real_escape_string', $_GET);
$_POST = array_map('mysql_real_escape_string', $_POST);
$_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);
}
else
{
$_GET = array_map('stripslashes', $_GET);
$_POST = array_map('stripslashes', $_POST);
$_COOKIE = array_map('stripslashes', $_COOKIE);
$_GET = array_map('mysql_real_escape_string', $_GET);
$_POST = array_map('mysql_real_escape_string', $_POST);
$_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);
}
?>
Re: Im new and i need help????
Posted: Tue Dec 30, 2014 4:59 pm
by Sim
what's the error??
Re: Im new and i need help????
Posted: Tue Dec 30, 2014 6:18 pm
by dave3460
Silly question
Have you changed your sql to your own and also made a table in php admin named battle?
or just posted the connect .php as it was?
Re: Im new and i need help????
Posted: Sat Jan 31, 2015 4:24 pm
by treesnake1234
Sorry for the delay here is the errors, is there anything else you need?
Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in C:\wamp\www\projectbattle\connect.php on line 11
Call Stack
# Time Memory Function Location
1 0.0230 248200 {main}( ) ..\authenticate.php:0
2 0.0240 255536 include( 'C:\wamp\www\projectbattle\connect.php' ) ..\authenticate.php:2
3 0.0340 264520 array_map ( ) ..\connect.php:11
4 0.0340 265304 mysqli_real_escape_string ( ) ..\connect.php:11
( ! ) Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in C:\wamp\www\projectbattle\connect.php on line 11
Call Stack
# Time Memory Function Location
1 0.0230 248200 {main}( ) ..\authenticate.php:0
2 0.0240 255536 include( 'C:\wamp\www\projectbattle\connect.php' ) ..\authenticate.php:2
3 0.0340 264520 array_map ( ) ..\connect.php:11
4 0.0390 266008 mysqli_real_escape_string ( ) ..\connect.php:11
( ! ) Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in C:\wamp\www\projectbattle\connect.php on line 11
Call Stack
# Time Memory Function Location
1 0.0230 248200 {main}( ) ..\authenticate.php:0
2 0.0240 255536 include( 'C:\wamp\www\projectbattle\connect.php' ) ..\authenticate.php:2
3 0.0340 264520 array_map ( ) ..\connect.php:11
4 0.0400 266288 mysqli_real_escape_string ( ) ..\connect.php:11
( ! ) Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\projectbattle\connect.php:11) in C:\wamp\www\projectbattle\authenticate.php on line 3
Call Stack
# Time Memory Function Location
1 0.0230 248200 {main}( ) ..\authenticate.php:0
2 0.0410 258752 session_start ( ) ..\authenticate.php:3
( ! ) Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\projectbattle\connect.php:11) in C:\wamp\www\projectbattle\authenticate.php on line 4
Call Stack
# Time Memory Function Location
1 0.0230 248200 {main}( ) ..\authenticate.php:0
2 0.0420 259616 header ( ) ..\authenticate.php:4
( ! ) Warning: mysql_fetch_array() expects parameter 1 to be resource, object given in C:\wamp\www\projectbattle\authenticate.php on line 16
Call Stack
# Time Memory Function Location
1 0.0230 248200 {main}( ) ..\authenticate.php:0
2 0.0890 262456 mysql_fetch_array ( ) ..\authenticate.php:16
Re: Im new and i need help????
Posted: Sun Apr 05, 2015 11:05 pm
by gedq
ok I'm confused; the source says mysql_real_escape_string, the error message says mysqli_real_escape_string. If they're getting swapped somewhere then it's easy:
http://php.net/manual/en/mysqli.real-escape-string.php wrote:Procedural style
string mysqli_real_escape_string ( mysqli $link , string $escapestr )
This function is used to create a legal SQL string that you can use in an SQL statement. The given string is encoded to an escaped SQL string, taking into account the current character set of the connection.
It looks like that array_map is calling mysqli_real_escape_string with just the string to be escaped, no db link. Not sure how you'd fix that tbh, I'm not a big fan of mysqli, I hugely prefer pdo.
Re: Im new and i need help????
Posted: Mon Apr 06, 2015 1:26 pm
by hallsofvallhalla
seems something is wrong on your authenticate page. Need to show that page.