Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Register your account to receive email notifications when new services and mods are added.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: error help v1  (Read 906 times)

smkin

  • Basic Member
  • *
  • Reputation Power: 4
  • smkin has no influence.
  • Offline Offline
  • Posts: 10
    • View Profile
error help v1
« on: November 22, 2009, 05:34:25 PM »
help with errors on v1
Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xamp\xampp\htdocs\\register.php on line 36

Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\xamp\xampp\htdocs\\register.php on line 37

Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xamp\xampp\htdocs\\register.php on line 51

Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\xamp\xampp\htdocs\\register.php on line 52

Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xamp\xampp\htdocs\\register.php on line 60

Warning: mysql_insert_id() expects parameter 1 to be resource, null given in C:\xamp\xampp\htdocs\\register.php on line 61

Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xamp\xampp\htdocs\\register.php on line 62



here is the lines
line 36...$q=mysql_query("SELECT * FROM users WHERE username='{$username}'",$c);

line 37...if(mysql_num_rows($q))

line 51...$q=mysql_query("SELECT * FROM users WHERE lastip='$ip' AND userid={$_POST['ref']}",$c);

line 52...if(mysql_num_rows($q))

line
60..mysql_query("INSERT INTO users (username, login_name, userpass,
level, money, crystals, donatordays, user_level, energy, maxenergy,
will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup,
email, bankmoney, lastip) VALUES( '{$username}', '{$username}',
md5('{$_POST['password']}'), 1, $sm, 0, 0, 1, 12, 12, 100, 100, 5, 5,
100, 100, 1, 'Male', unix_timestamp(), '{$_POST['email']}', -1,
'$ip')", $c);

line 61...$i=mysql_insert_id($c);

line 62...mysql_query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10)", $c);



-------------------------------------------------------------------------------------------



this is the page




<?php
session_start();
print "<html>
<head>
<title>Your Game Name</title>
<style>
body { font-family:Verdana;font-size:9pt;color: black;
background-color:#C3C3C3;
scrollbar-base-color: #005B70;
scrollbar-arrow-color: #F3960B;
scrollbar-DarkShadow-Color: #000000; }
a:visited,a:active,a:hover,a:link { color: black;text-decoration: none; }
table,tr,td { font-size:9pt; }
img { border:none; }
</style>
</head>
<body><img src='logo.png'><br />";

$ip = $_SERVER['REMOTE_ADDR'];

if(file_exists('ipbans/'.$ip))
{
die("<b><font color=red size=+1>Your IP has been banned, there is no way around this.</font></b></body></html>");
}
require "mysql.php";
global $c;
if($_POST['username'])
{
$sm=100;
if($_POST['promo'] == "Your Promo Code Here")
{
$sm+=100;
}
$username=$_POST['username'];
$username=str_replace(array("<", ">"), array("&lt;", "&gt;"), $username);
$q=mysql_query("SELECT * FROM users WHERE username='{$username}'",$c);
if(mysql_num_rows($q))
{
print "Username already in use. Choose another.";
}
else if($_POST['password'] != $_POST['cpassword'])
{
print "The passwords did not match, go back and try again.";
}
else
{
$_POST['ref'] = abs((int) $_POST['ref']);
$ip = $_SERVER['REMOTE_ADDR'];
$q=mysql_query("SELECT * FROM users WHERE lastip='$ip' AND userid={$_POST['ref']}",$c);
if(mysql_num_rows($q))
{
die("No creating referral multies. Bad dog.");
}
if($_POST['ref']) {
$q=mysql_query("SELECT * FROM users WHERE userid={$_POST['ref']}",$c);
$r=mysql_fetch_array($q);
}
mysql_query("INSERT INTO users (username, login_name, userpass, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip) VALUES( '{$username}', '{$username}', md5('{$_POST['password']}'), 1, $sm, 0, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, 'Male', unix_timestamp(), '{$_POST['email']}', -1, '$ip')", $c);
$i=mysql_insert_id($c);
mysql_query("INSERT INTO userstats VALUES($i, 10, 10, 10, 10, 10)", $c);

if($_POST['ref']) {
require "global_func.php";
mysql_query("UPDATE users SET crystals=crystals+2 WHERE userid={$_POST['ref']}",$c);
event_add($_POST['ref'],"For refering $username to the game, you have earnt 2 valuable crystals!",$c);
mysql_query("INSERT INTO referals VALUES('', {$_POST['ref']}, $i, unix_timestamp(),'{$r['lastip']}','$ip')", $c);
}
print "You have signed up, enjoy the game.<br>
&gt; <a href='login.php'>Login</a>";
}
}
else
{
print "<h3>Your Game Name Registration</h3>";
print "<form action=register.php method=post>Username: <input type=text name=username><br>
Password: <input type=password name=password><br>
Confirm Password: <input type=password name=cpassword><br>
Email: <input type=text name=email><br>
Promo Code: <input type=text name=promo><br>
<input type=hidden name=ref value='";
if($_GET['REF']) { print $_GET['REF']; }
print "'>
<input type=submit value=Submit></form><br />
&gt; <a href='login.php'>Go Back</a>";
}
print "</body></html>";
?>

----------------------------------------------------------------------

any help welcome
Logged

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: error help v1
« Reply #1 on: November 23, 2009, 11:51:20 AM »
Give me 10, ill re-code it.
Logged
Project Choosen - 10%
Daniel - Hanson . Com

smkin

  • Basic Member
  • *
  • Reputation Power: 4
  • smkin has no influence.
  • Offline Offline
  • Posts: 10
    • View Profile
Re: error help v1
« Reply #2 on: November 23, 2009, 11:54:20 AM »
thanks m8 is there  fault in the code
Logged

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: error help v1
« Reply #3 on: November 23, 2009, 12:11:49 PM »
<?php
session_start
();
?><html>
<head>
<title>Your Game Name</title>
<style>
body { font-family:Verdana;font-size:9pt;color: black;
background-color:#C3C3C3;
scrollbar-base-color: #005B70;
scrollbar-arrow-color: #F3960B;
scrollbar-DarkShadow-Color: #000000; }
a:visited,a:active,a:hover,a:link { color: black;text-decoration: none; }
table,tr,td { font-size:9pt; }
img { border:none; }
</style>
</head>
<body><img src='logo.png'><br />
<?
$ip 
$_SERVER['REMOTE_ADDR'];
if(
file_exists('ipbans/'.$ip))
{
die(
"<b><font color=red size=+1>Your IP has been banned, there is no way around this.</font></b></body></html>");
}
require 
"mysql.php";
global 
$c;
if(
$_POST['username'])
{
$sm=100;
if(
$_POST['promo'] == "Your Promo Code Here")
{
$sm+=100;
}
$username=$_POST['username'];
$username=str_replace(array("<"">"), array("&lt;""&gt;"), $username);
$query sprintf("SLECT * FROM `users` WHERE `username`='%s'"$username);
$i mysql_query($query$c);
if(
mysql_num_rows($i))
{
print 
"Username already in use. Choose another.";
}
else if(
$_POST['password'] != $_POST['cpassword'])
{
print 
"The passwords did not match, go back and try again.";
}
else
{
$_POST['ref'] = abs((int) $_POST['ref']);
$ip $_SERVER['REMOTE_ADDR'];
$query sprintf("SLECT * FROM `users` WHERE `lastip`='%s' AND userid=%u"$ip$_POST['ref']);
$i mysql_query($query$c);
if(
mysql_num_rows($i))
{
die(
"No creating referral multies. Bad dog.");
}
if(
$_POST['ref']) {
$query sprintf("SLECT * FROM `users` WHERE userid=%u"$_POST['ref']);
$i mysql_query($query$c);
$r=mysql_fetch_array($i);
}
$insertuser sprintf("INSERT INTO users (username, login_name, userpass, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip) VALUES( '%s', '%s', md5('%s'), 1, %u, 0, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, 'Male', unix_timestap(), '%s', -1, '%s')"$username$username$_POST['password'], $sm$_POST['email'], $ip);
mysql_query($insertuser$c);
$i=mysql_insert_id();
$insertstats sprintf("INSERT INTO userstats VALUES(%u, 10, 10, 10, 10, 10)"$i)
mysql_query($insertstats$c);

if(
$_POST['ref']) {
require 
"global_func.php";
mysql_query("UPDATE users SET crystals=crystals+2 WHERE userid={$_POST['ref']}",$c);
event_add($_POST['ref'],"For refering $username to the game, you have earnt 2 valuable crystals!",$c);
mysql_query("INSERT INTO referals VALUES('', {$_POST['ref']}, $i, unix_timestamp(),'{$r['lastip']}','$ip')"$c);
}
print 
"You have signed up, enjoy the game.<br>
&gt; <a href='login.php'>Login</a>"
;
}
}
else
{
print 
"<h3>Your Game Name Registration</h3>";
print 
"<form action=register.php method=post>Username: <input type=text name=username><br>
Password: <input type=password name=password><br>
Confirm Password: <input type=password name=cpassword><br>
Email: <input type=text name=email><br>
Promo Code: <input type=text name=promo><br>
<input type=hidden name=ref value='"
;
if(
$_GET['REF']) { print $_GET['REF']; }
print 
"'>
<input type=submit value=Submit></form><br />
&gt; <a href='login.php'>Go Back</a>"
;
}
?></body></html>
Logged
Project Choosen - 10%
Daniel - Hanson . Com

smkin

  • Basic Member
  • *
  • Reputation Power: 4
  • smkin has no influence.
  • Offline Offline
  • Posts: 10
    • View Profile
Re: error help v1
« Reply #4 on: November 23, 2009, 12:15:42 PM »
mysql_query($insertstats, $c);



that bit of code is throwing an error
Logged

Danny696

  • Senior Member
  • ****
  • Reputation Power: 317
  • Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.Danny696 is a force to reckon with.
  • Offline Offline
  • Posts: 540
    • View Profile
    • WWW
Re: error help v1
« Reply #5 on: November 23, 2009, 12:39:32 PM »
mysql_query($insertstats); try that
Logged
Project Choosen - 10%
Daniel - Hanson . Com

smkin

  • Basic Member
  • *
  • Reputation Power: 4
  • smkin has no influence.
  • Offline Offline
  • Posts: 10
    • View Profile
Re: error help v1
« Reply #6 on: November 23, 2009, 12:49:56 PM »
right got rid of the error you changed it to what you said and added an ;at the end of the line before



now it shows this



Your IP has been banned, there is no way around this."); } require "mysql.php"; global $c; if($_POST['username']) { $sm=100; if($_POST['promo'] == "Your Promo Code Here") { $sm+=100; } $username=$_POST['username']; $username=str_replace(array("<", ">"), array("<", ">"), $username); $query = sprintf("SLECT * FROM `users` WHERE `username`='%s'", $username); $i = mysql_query($query, $c); if(mysql_num_rows($i)) { print "Username already in use. Choose another."; } else if($_POST['password'] != $_POST['cpassword']) { print "The passwords did not match, go back and try again."; } else { $_POST['ref'] = abs((int) $_POST['ref']); $ip = $_SERVER['REMOTE_ADDR']; $query = sprintf("SLECT * FROM `users` WHERE `lastip`='%s' AND userid=%u", $ip, $_POST['ref']); $i = mysql_query($query, $c); if(mysql_num_rows($i)) { die("No creating referral multies. Bad dog."); } if($_POST['ref']) { $query = sprintf("SLECT * FROM `users` WHERE userid=%u", $_POST['ref']); $i = mysql_query($query, $c); $r=mysql_fetch_array($i); } $insertuser = sprintf("INSERT INTO users (username, login_name, userpass, level, money, crystals, donatordays, user_level, energy, maxenergy, will, maxwill, brave, maxbrave, hp, maxhp, location, gender, signedup, email, bankmoney, lastip) VALUES( '%s', '%s', md5('%s'), 1, %u, 0, 0, 1, 12, 12, 100, 100, 5, 5, 100, 100, 1, 'Male', unix_timestap(), '%s', -1, '%s')", $username, $username, $_POST['password'], $sm, $_POST['email'], $ip); mysql_query($insertuser, $c); $i=mysql_insert_id(); $insertstats = sprintf("INSERT INTO userstats VALUES(%u, 10, 10, 10, 10, 10)", $i); mysql_query($insertstats); if($_POST['ref']) { require "global_func.php"; mysql_query("UPDATE users SET crystals=crystals+2 WHERE userid={$_POST['ref']}",$c); event_add($_POST['ref'],"For refering $username to the game, you have earnt 2 valuable crystals!",$c); mysql_query("INSERT INTO referals VALUES('', {$_POST['ref']}, $i, unix_timestamp(),'{$r['lastip']}','$ip')", $c); } print "You have signed up, enjoy the game.
> Login"; } } else { print "



on the page
Logged

smkin

  • Basic Member
  • *
  • Reputation Power: 4
  • smkin has no influence.
  • Offline Offline
  • Posts: 10
    • View Profile
Re: error help v1
« Reply #7 on: November 23, 2009, 01:00:46 PM »
right just added php to that <? and it removed all that from the srcean but still given out the same errors plus more




Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\xampp\htdocs\m1\MonoCountry Source Codes Version 1.1\files\register.php on line 36

Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\xampp\xampp\htdocs\m1\MonoCountry Source Codes Version 1.1\files\register.php on line 37

Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\xampp\htdocs\m1\MonoCountry Source Codes Version 1.1\files\register.php on line 50

Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\xampp\xampp\htdocs\m1\MonoCountry Source Codes Version 1.1\files\register.php on line 51

Warning: mysql_query() expects parameter 2 to be resource, null given in C:\xampp\xampp\htdocs\m1\MonoCountry Source Codes Version 1.1\files\register.php on line 61

Warning: mysql_insert_id() [function.mysql-insert-id]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\xampp\htdocs\m1\MonoCountry Source Codes Version 1.1\files\register.php on line 62

Warning: mysql_insert_id() [function.mysql-insert-id]: A link to the server could not be established in C:\xampp\xampp\htdocs\m1\MonoCountry Source Codes Version 1.1\files\register.php on line 62

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\xampp\htdocs\m1\MonoCountry Source Codes Version 1.1\files\register.php on line 64

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\xampp\htdocs\m1\MonoCountry Source Codes Version 1.1\files\register.php on line 64
Logged
 


This forum is now closed and has moved to a new location! Click here to find out why.