Im new and i need help????

New to the site? Place a post here and let us know about you and what brings you to the site. T
Post Reply
treesnake1234
Posts: 2
Joined: Mon Dec 29, 2014 3:53 pm

Im new and i need help????

Post 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);
}
?>
Sim
Posts: 412
Joined: Sat Dec 26, 2009 5:37 pm

Re: Im new and i need help????

Post by Sim »

what's the error??
oRPG Creator - Make Your Own Browser Game
oRPG Creator on Facebook
dave3460
Posts: 117
Joined: Wed Jul 01, 2009 2:13 pm

Re: Im new and i need help????

Post 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?
treesnake1234
Posts: 2
Joined: Mon Dec 29, 2014 3:53 pm

Re: Im new and i need help????

Post 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
gedq
Posts: 18
Joined: Sun Apr 05, 2015 9:53 pm

Re: Im new and i need help????

Post 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.
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: Im new and i need help????

Post by hallsofvallhalla »

seems something is wrong on your authenticate page. Need to show that page.
Post Reply

Return to “Say Hello”