mysql_num_rows

Σε αυτή την περιοχή μπορείτε να βρείτε ή να αναζητήσετε πληροφορίες σχετικές με την PHP

Συντονιστές: WebDev Moderators, Super-Moderators, PHP Moderators

Απάντηση
xatzh
Δημοσιεύσεις: 15
Εγγραφή: 11 Αύγ 2007 16:15

mysql_num_rows

Δημοσίευση από xatzh » 19 Οκτ 2008 00:08

prospa8o na ftiakso ena asfales register sto server ala mou bgazi to minima

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\EasyPHP 2.0b1\www\register.php on line 152
Account registered successfully.

otan prospa8o na kano register mipos kseri kapios na boi8isi okodikas ine o parakato
kseri kanenas na boi8isi ti akribos ine to problima

http://img124.imageshack.us/my.php?image=zxcnv9.jpg

Κώδικας: Επιλογή όλων

<?php
	require_once './inc/class.captcha.php';
	// Configurations
	$myhost="localhost";
	$mypass="root";
	$myuser="root";
	$mydbacc="accounts";
	$mydbdata="l2jdb";
	$serveraddress="127.0.0.1";
	$serverport=3306;
	// Domt Edit after this
	mysql_connect&#40;$myhost,$myuser,$mypass&#41;;
?>
<html xmlns="http&#58;//www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Eudemons Register</title>
<script type="text/javascript" src="./inc/md5.js"></script>
</head>
<STYLE type='text/css'>
body
&#123;
	FONT&#58; 13px Arial;
&#125;
td
&#123;
	FONT&#58; 13px Arial;
&#125;
.Label1 &#123;
	TEXT-ALIGN&#58; right
&#125;
.Label &#123;
	PADDING-LEFT&#58; 5px
&#125;
.Label1 &#123;
	PADDING-LEFT&#58; 5px
&#125;
.Label &#123;
	PADDING-BOTTOM&#58; 16px; FONT&#58; 13px Arial; VERTICAL-ALIGN&#58; top! important; WIDTH&#58; 100px; COLOR&#58; #000; WHITE-SPACE&#58; nowrap
&#125;
.it &#123;
	WIDTH&#58; 160px
&#125;
#ipassword &#123;
	WIDTH&#58; 160px
&#125;
#ipassword2 &#123;
	WIDTH&#58; 160px
&#125;
.it3 &#123;
	VERTICAL-ALIGN&#58; top; WIDTH&#58; 160px
&#125;
.it1 &#123;	WIDTH&#58; 160px
&#125;
.Butt &#123;
	BORDER-RIGHT&#58; #2854a7 1px solid; BORDER-TOP&#58; #7cbaff 1px solid; FONT&#58; bold 12px Arial, Helvetica, sans-serif; BORDER-LEFT&#58; #7cbaff 1px solid; COLOR&#58; #ffffff; BORDER-BOTTOM&#58; #2854a7 1px solid; BACKGROUND-COLOR&#58; #3366cc
&#125;
</STYLE>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" bgcolor="#ffffff">
<DIV align="center">
<br />
<b>Eudemons Online Account Register</b>
<br />
<br />
<form method='post' action='register.php?act=register'>
      <TABLE width="312">
        <TBODY>
        <TR>
          <TD id=GoodStuff style="PADDING-LEFT&#58; 0px; MARGIN-LEFT&#58; 0px">
            <DIV id=theform style="PADDING-LEFT&#58; 0px">
            <TABLE class=fdata width="323" height="229">
              <TBODY>
              <TR>
                <TD class=Label align="right" height="32"><span style="font-size&#58; 9pt">UserID&#58;</span></TD>
                <TD class=it3 height="32">
				<INPUT class=it style="FONT-SIZE&#58; 9pt" name="id" id="id"><span style="font-size&#58; 9pt">
				</span></TR>
              <TR>
                <TD class=Label align="right" height="37"><span style="font-size&#58; 9pt">Password&#58;</span></TD>
                <TD class=it3 height="37">
				<INPUT class=it id="ipassword" style="FONT-SIZE&#58; 9pt" type=password maxLength=12 name=pass></TD>
                </TR>
              <TR>
                <TD class=Label align="right" height="32"><span style="font-size&#58; 9pt">Retype Password&#58;</span></TD>
                <TD class=it3 height="32">
				<input class=it1 id="ipassword" style="FONT-SIZE&#58; 9pt" type=password maxlength=12 name=retpass></TD>
                </TR>
              <TR>
                <TD class=Label align="right" height="32"><span style="font-size&#58; 9pt">Type Check Code&#58;</span></TD>
                <TD class=it3 height="32">
					<input name='CheckCode' size='20' maxlength='6'class=it style="FONT-SIZE&#58; 9pt"></TD>
                </TR>
              <TR>
                <TD height="25" align="right">Check Code&#58;</TD>
                <TD height="25"><span style="font-size&#58; 9pt"><img src='./inc/img.php' width='200' height='60' alt='Visual CAPTCHA' 
  style='border&#58; 1px solid #000000; padding&#58; 2px;' /></TD></TR>
              <TR>
                <TD></TD>
                <TD style="FONT-SIZE&#58; 14px; VERTICAL-ALIGN&#58; middle">
				<span style="font-size&#58; 9pt"><input type="hidden" name="hash"><input class=Butt type=submit onClick="hash.value = login&#40;pass.value&#41;" value='Register' name=B1></span></TD>
                </TR></TBODY></TABLE>
            </DIV></TD></TR></TBODY></TABLE></FORM>
			<?php
			mysql_select_db&#40;$mydbacc&#41;;
			$res = mysql_query&#40;"SELECT count&#40;*&#41;account;"&#41;;
			$val = mysql_fetch_array&#40;$res&#41;;
			echo "Total Accounts&#58; ".$val&#91;0&#93;."<br />";
			
			mysql_select_db&#40;$mydbdata&#41;;
			$res = mysql_query&#40;"SELECT count&#40;*&#41;cq_user;"&#41;;
			$val = mysql_fetch_array&#40;$res&#41;;
			echo "Total Characters&#58; ".$val&#91;0&#93;."<br />";
			
			echo "Server Status&#58; ";
			$fp = @fsockopen&#40;$serveraddress, $serverport, $errno, $errstr, 1&#41;;
			if &#40;!$fp&#41; &#123;
				echo "<font style='color&#58; #FF3300'><B>Offline</B></font></br>";
			&#125;
			else
			&#123;
				echo "<font style='color&#58; #009933'><B>Online</B></font></br>";
				fclose&#40;$fp&#41;;
			&#125;
			?>
			<center>
			<?php
			if&#40;$_GET&#91;'act'&#93; == "register"&#41;
			&#123;
				if&#40;PhpCaptcha&#58;&#58;Validate&#40;$_POST&#91;'CheckCode'&#93;&#41;&#41;
				&#123;
					mysql_select_db&#40;$mydbacc&#41;;
					$userid = trim&#40;$_POST&#91;'id'&#93;&#41;;
					$password=trim&#40;$_POST&#91;'pass'&#93;&#41;;
					$passretype=trim&#40;$_POST&#91;'retpass'&#93;&#41;;
					$hash=$_POST&#91;'hash'&#93;;
					if&#40;!ereg&#40;"^&#91;0-9a-z&#93;&#123;4,12&#125;$",$userid&#41;&#41;
					&#123;
						echo "Only letters from \"a\" to \"z\" and numbers, lenght of 4 to 12 characters";
					&#125;
					else
					&#123;
						if&#40;$password == $passretype&#41;
						&#123;
							if&#40;!ereg&#40;"^&#91;0-9a-zA-Z&#93;&#123;4,12&#125;$",$password&#41;&#41;
							&#123;
								echo "Only letters or numbers, lenght of 4 to 12 characters";
							&#125;
							else
							&#123;
								$res = mysql_query&#40;"select * from account where name = '".$userid."' order by id desc"&#41;;
								if&#40;mysql_num_rows&#40;$res&#41; == 0&#41;
								&#123;
									mysql_query&#40;"insert into accounts &#40;name,Password,Reg_date&#41; values &#40;'".$userid."','".$hash."','".date&#40;"y-m-d H&#58;i&#58;s", time&#40;&#41;&#41;."'&#41;"&#41;;
									echo "Account registered successfully.";
								&#125;
								else
								&#123;
									echo "Account Already exists in database.";
								&#125;
							&#125;
						&#125;
						else
						&#123;
							echo "Password not equal to Retyped Password.";
						&#125;
					&#125;
				&#125;
				else
				&#123;
					echo "Check Code is Wrong";
				&#125;
			&#125;
			?>
			</center>
      </DIV>
</body>
</html>

Άβαταρ μέλους
Pavel
Honorary Member
Δημοσιεύσεις: 1046
Εγγραφή: 08 Αύγ 2003 00:05
Τοποθεσία: UK

mysql_num_rows

Δημοσίευση από Pavel » 19 Οκτ 2008 01:02

Κώδικας: Επιλογή όλων

$res = mysql_query&#40;"select * from account where name = '".$userid."' order by id desc"&#41;;
if&#40;mysql_num_rows&#40;$res&#41; == 0&#41;
Βασικά δεν ελέγχεις αν ήταν πετυχημένο το query.

Κάντο ως εξής

Κώδικας: Επιλογή όλων

$res = mysql_query&#40;"select * from account where name = '".$userid."' order by id desc"&#41;;
if &#40;$res&#41;
&#123;
     if&#40;mysql_num_rows&#40;$res&#41; == 0&#41;
     &#123;
         code here
     &#125;
&#125;
else
&#123;
     echo mysql_error&#40;&#41;;
     die&#40;&#41;;
&#125;
Έτσι θα δεις για ποιο λόγο σου βγάζει αυτό το σφάλμα.
Εσύ είσαι τρελός.

xatzh
Δημοσιεύσεις: 15
Εγγραφή: 11 Αύγ 2007 16:15

mysql_num_rows

Δημοσίευση από xatzh » 19 Οκτ 2008 01:40

katarxas eyxaristo poy apantises toso grigora tora ime ke ligo asxetos apo php to register ayto to brika etimo gia to sigekrimeno server an mporouses grapse mou to olo mazi na to dokimaso ke pes mou ti alo 8es na sou eksigiso ama mporis na boi8isis giati palebo me ayto 2 meres
eyxaristo

Άβαταρ μέλους
Pavel
Honorary Member
Δημοσιεύσεις: 1046
Εγγραφή: 08 Αύγ 2003 00:05
Τοποθεσία: UK

mysql_num_rows

Δημοσίευση από Pavel » 19 Οκτ 2008 02:02

Κώδικας: Επιλογή όλων

<?php
   require_once './inc/class.captcha.php';
   // Configurations
   $myhost="localhost";
   $mypass="root";
   $myuser="root";
   $mydbacc="accounts";
   $mydbdata="l2jdb";
   $serveraddress="127.0.0.1";
   $serverport=3306;
   // Domt Edit after this
   mysql_connect&#40;$myhost,$myuser,$mypass&#41;;
?>
<html xmlns="http&#58;//www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Eudemons Register</title>
<script type="text/javascript" src="./inc/md5.js"></script>
</head>
<STYLE type='text/css'>
body
&#123;
   FONT&#58; 13px Arial;
&#125;
td
&#123;
   FONT&#58; 13px Arial;
&#125;
.Label1 &#123;
   TEXT-ALIGN&#58; right
&#125;
.Label &#123;
   PADDING-LEFT&#58; 5px
&#125;
.Label1 &#123;
   PADDING-LEFT&#58; 5px
&#125;
.Label &#123;
   PADDING-BOTTOM&#58; 16px; FONT&#58; 13px Arial; VERTICAL-ALIGN&#58; top! important; WIDTH&#58; 100px; COLOR&#58; #000; WHITE-SPACE&#58; nowrap
&#125;
.it &#123;
   WIDTH&#58; 160px
&#125;
#ipassword &#123;
   WIDTH&#58; 160px
&#125;
#ipassword2 &#123;
   WIDTH&#58; 160px
&#125;
.it3 &#123;
   VERTICAL-ALIGN&#58; top; WIDTH&#58; 160px
&#125;
.it1 &#123;   WIDTH&#58; 160px
&#125;
.Butt &#123;
   BORDER-RIGHT&#58; #2854a7 1px solid; BORDER-TOP&#58; #7cbaff 1px solid; FONT&#58; bold 12px Arial, Helvetica, sans-serif; BORDER-LEFT&#58; #7cbaff 1px solid; COLOR&#58; #ffffff; BORDER-BOTTOM&#58; #2854a7 1px solid; BACKGROUND-COLOR&#58; #3366cc
&#125;
</STYLE>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" bgcolor="#ffffff">
<DIV align="center">
<br />
<b>Eudemons Online Account Register</b>
<br />
<br />
<form method='post' action='register.php?act=register'>
      <TABLE width="312">
        <TBODY>
        <TR>
          <TD id=GoodStuff style="PADDING-LEFT&#58; 0px; MARGIN-LEFT&#58; 0px">
            <DIV id=theform style="PADDING-LEFT&#58; 0px">
            <TABLE class=fdata width="323" height="229">
              <TBODY>
              <TR>
                <TD class=Label align="right" height="32"><span style="font-size&#58; 9pt">UserID&#58;</span></TD>
                <TD class=it3 height="32">
            <INPUT class=it style="FONT-SIZE&#58; 9pt" name="id" id="id"><span style="font-size&#58; 9pt">
            </span></TR>
              <TR>
                <TD class=Label align="right" height="37"><span style="font-size&#58; 9pt">Password&#58;</span></TD>
                <TD class=it3 height="37">
            <INPUT class=it id="ipassword" style="FONT-SIZE&#58; 9pt" type=password maxLength=12 name=pass></TD>
                </TR>
              <TR>
                <TD class=Label align="right" height="32"><span style="font-size&#58; 9pt">Retype Password&#58;</span></TD>
                <TD class=it3 height="32">
            <input class=it1 id="ipassword" style="FONT-SIZE&#58; 9pt" type=password maxlength=12 name=retpass></TD>
                </TR>
              <TR>
                <TD class=Label align="right" height="32"><span style="font-size&#58; 9pt">Type Check Code&#58;</span></TD>
                <TD class=it3 height="32">
               <input name='CheckCode' size='20' maxlength='6'class=it style="FONT-SIZE&#58; 9pt"></TD>
                </TR>
              <TR>
                <TD height="25" align="right">Check Code&#58;</TD>
                <TD height="25"><span style="font-size&#58; 9pt"><img src='./inc/img.php' width='200' height='60' alt='Visual CAPTCHA'
  style='border&#58; 1px solid #000000; padding&#58; 2px;' /></TD></TR>
              <TR>
                <TD></TD>
                <TD style="FONT-SIZE&#58; 14px; VERTICAL-ALIGN&#58; middle">
            <span style="font-size&#58; 9pt"><input type="hidden" name="hash"><input class=Butt type=submit onClick="hash.value = login&#40;pass.value&#41;" value='Register' name=B1></span></TD>
                </TR></TBODY></TABLE>
            </DIV></TD></TR></TBODY></TABLE></FORM>
         <?php
         mysql_select_db&#40;$mydbacc&#41;;
         $res = mysql_query&#40;"SELECT count&#40;*&#41;account;"&#41;;
         $val = mysql_fetch_array&#40;$res&#41;;
         echo "Total Accounts&#58; ".$val&#91;0&#93;."<br />";
         
         mysql_select_db&#40;$mydbdata&#41;;
         $res = mysql_query&#40;"SELECT count&#40;*&#41;cq_user;"&#41;;
         $val = mysql_fetch_array&#40;$res&#41;;
         echo "Total Characters&#58; ".$val&#91;0&#93;."<br />";
         
         echo "Server Status&#58; ";
         $fp = @fsockopen&#40;$serveraddress, $serverport, $errno, $errstr, 1&#41;;
         if &#40;!$fp&#41; &#123;
            echo "<font style='color&#58; #FF3300'><B>Offline</B></font></br>";
         &#125;
         else
         &#123;
            echo "<font style='color&#58; #009933'><B>Online</B></font></br>";
            fclose&#40;$fp&#41;;
         &#125;
         ?>
         <center>
         <?php
         if&#40;$_GET&#91;'act'&#93; == "register"&#41;
         &#123;
            if&#40;PhpCaptcha&#58;&#58;Validate&#40;$_POST&#91;'CheckCode'&#93;&#41;&#41;
            &#123;
               mysql_select_db&#40;$mydbacc&#41;;
               $userid = trim&#40;$_POST&#91;'id'&#93;&#41;;
               $password=trim&#40;$_POST&#91;'pass'&#93;&#41;;
               $passretype=trim&#40;$_POST&#91;'retpass'&#93;&#41;;
               $hash=$_POST&#91;'hash'&#93;;
               if&#40;!ereg&#40;"^&#91;0-9a-z&#93;&#123;4,12&#125;$",$userid&#41;&#41;
               &#123;
                  echo "Only letters from \"a\" to \"z\" and numbers, lenght of 4 to 12 characters";
               &#125;
               else
               &#123;
                  if&#40;$password == $passretype&#41;
                  &#123;
                     if&#40;!ereg&#40;"^&#91;0-9a-zA-Z&#93;&#123;4,12&#125;$",$password&#41;&#41;
                     &#123;
                        echo "Only letters or numbers, lenght of 4 to 12 characters";
                     &#125;
                     else
                     &#123;
                        $res = mysql_query&#40;"select * from account where name = '".$userid."' order by id desc"&#41;;
                        if &#40;$res&#41;
                        &#123;
	                        if&#40;mysql_num_rows&#40;$res&#41; == 0&#41;
	                        &#123;
	                           mysql_query&#40;"insert into accounts &#40;name,Password,Reg_date&#41; values &#40;'".$userid."','".$hash."','".date&#40;"y-m-d H&#58;i&#58;s", time&#40;&#41;&#41;."'&#41;"&#41;;
	                           echo "Account registered successfully.";
	                        &#125;
	                        else
	                        &#123;
	                           echo "Account Already exists in database.";
	                        &#125;
	                      &#125;
	                      else
	                      &#123;
	                      	echo mysql_error&#40;&#41;."<br /><br />"."select * from account where name = '".$userid."' order by id desc";
	                      	die&#40;&#41;;
	                      &#125;
                     &#125;
                  &#125;
                  else
                  &#123;
                     echo "Password not equal to Retyped Password.";
                  &#125;
               &#125;
            &#125;
            else
            &#123;
               echo "Check Code is Wrong";
            &#125;
         &#125;
         ?>
         </center>
      </DIV>
</body>
</html>
δοκίμασε αυτό για να δεις τι σφάλμα βγάζει.
Εσύ είσαι τρελός.

xatzh
Δημοσιεύσεις: 15
Εγγραφή: 11 Αύγ 2007 16:15

mysql_num_rows

Δημοσίευση από xatzh » 19 Οκτ 2008 02:21

Table 'l2jdb.account' doesn't exist

select * from account where name = 'qqqqqqq' order by id desc



ayto mou ebgale to pio pano ke otan trexo ti selida gia na mpo proti fora mpou bgazi

Notice: Undefined index: act in C:\Program Files\EasyPHP 2.0b1\www\register.php on line 128
:D

Άβαταρ μέλους
Pavel
Honorary Member
Δημοσιεύσεις: 1046
Εγγραφή: 08 Αύγ 2003 00:05
Τοποθεσία: UK

mysql_num_rows

Δημοσίευση από Pavel » 19 Οκτ 2008 02:25

Οπότε αν φτιάξεις τον συγκεκριμένο πίνακα, θα είσαι ΟΚ :)

Ξαναδιάβασε τις οδηγίες εγκατάστασης του script (ή από εκεί που το πήρες)

Pavel
Εσύ είσαι τρελός.

xatzh
Δημοσιεύσεις: 15
Εγγραφή: 11 Αύγ 2007 16:15

mysql_num_rows

Δημοσίευση από xatzh » 19 Οκτ 2008 02:27

eriksa mia matia pali ala den brika kati mipos exete kati na protinete na kitakso
anebasa ke mia foto tis basis isos ayto boi8isi kalitera

http://img520.imageshack.us/my.php?imag ... 648oo7.png

an ayto bai8ai anebasa ke mia apo to localhost

http://img252.imageshack.us/my.php?imag ... 318ry2.jpg

Άβαταρ μέλους
dva_dev
Script Master
Δημοσιεύσεις: 3790
Εγγραφή: 16 Σεπ 2005 01:32
Επικοινωνία:

mysql_num_rows

Δημοσίευση από dva_dev » 19 Οκτ 2008 11:09

Το script είναι δικό σου ή έτοιμο;

Αν είναι δικό σου τσέκαρε τα ονόματα των πινάκων και τη σύνταξη των εντολών sql
βλέπω έναν πίνακα account και έναν δεύτερο accounts. O σωστός ποιός είναι;

xatzh
Δημοσιεύσεις: 15
Εγγραφή: 11 Αύγ 2007 16:15

mysql_num_rows

Δημοσίευση από xatzh » 19 Οκτ 2008 20:51

accounts eki blepo na grafonte ta account ton pexton
poy ginonte automata mesa apo games. akoma palebo na to telioso 3 meres gamoto an kseri kapios as boi8isi
na to ftiakso pistebo ine leptomeria

Άβαταρ μέλους
dva_dev
Script Master
Δημοσιεύσεις: 3790
Εγγραφή: 16 Σεπ 2005 01:32
Επικοινωνία:

mysql_num_rows

Δημοσίευση από dva_dev » 19 Οκτ 2008 21:06

eiparhoun dyo tables me kontina onomata: account kai accounts. Poio apo ta dyo tables einai ayto poy krataei toys xrhstes soy giati kaneis select apo to proto kai kaneis insert sto deytero. Mallon apo oti katalabaino den yparxei periptosh toys xrhstes poy grafontai na mporeseis na toys deis oti einai eggegrammenoi afoy diabazeis allon pinaka.

xatzh
Δημοσιεύσεις: 15
Εγγραφή: 11 Αύγ 2007 16:15

mysql_num_rows

Δημοσίευση από xatzh » 19 Οκτ 2008 21:22

accounts ayto ine poy kratai toys xristes

Άβαταρ μέλους
dva_dev
Script Master
Δημοσιεύσεις: 3790
Εγγραφή: 16 Σεπ 2005 01:32
Επικοινωνία:

mysql_num_rows

Δημοσίευση από dva_dev » 19 Οκτ 2008 22:13

Αλλαξε αυτά

Κώδικας: Επιλογή όλων

$res = mysql_query&#40;"SELECT count&#40;*&#41;cq_user;"&#41;;
$res = mysql_query&#40;"SELECT count&#40;*&#41;account;"&#41;; 
$res = mysql_query&#40;"select * from account where name = '".$userid."' order by id desc"&#41;;
σε αυτά

Κώδικας: Επιλογή όλων

$res = mysql_query&#40;"SELECT count&#40;*&#41; FROM cq_user;"&#41;;
$res = mysql_query&#40;"SELECT count&#40;*&#41; FROM accounts;"&#41;; 
$res = mysql_query&#40;"select * from accounts where name = '".$userid."' order by id desc"&#41;;
Επίσης τα ελληνικά βοηθάνε πολύ (όχι την php ή την mysql αλλά εμάς).

xatzh
Δημοσιεύσεις: 15
Εγγραφή: 11 Αύγ 2007 16:15

mysql_num_rows

Δημοσίευση από xatzh » 19 Οκτ 2008 22:48

Sori gia ta elinika ala ama ta grapso kanonika 8a exi pola or8ografika la8i ta alaksa ayta
ke o kodikas einai o parakato.

Κώδικας: Επιλογή όλων

<?php
   require_once './inc/class.captcha.php';
   // Configurations
   $myhost="localhost";
   $mypass="";
   $myuser="root";
   $mydbacc="l2jdb";
   $mydbdata="accounts";
   $serveraddress="127.0.0.1";
   $serverport=3306;
   // Domt Edit after this
   mysql_connect&#40;$myhost,$myuser,$mypass&#41;;
?>
<html xmlns="http&#58;//www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Eudemons Register</title>
<script type="text/javascript" src="./inc/md5.js"></script>
</head>
<STYLE type='text/css'>
body
&#123;
   FONT&#58; 13px Arial;
&#125;
td
&#123;
   FONT&#58; 13px Arial;
&#125;
.Label1 &#123;
   TEXT-ALIGN&#58; right
&#125;
.Label &#123;
   PADDING-LEFT&#58; 5px
&#125;
.Label1 &#123;
   PADDING-LEFT&#58; 5px
&#125;
.Label &#123;
   PADDING-BOTTOM&#58; 16px; FONT&#58; 13px Arial; VERTICAL-ALIGN&#58; top! important; WIDTH&#58; 100px; COLOR&#58; #000; WHITE-SPACE&#58; nowrap
&#125;
.it &#123;
   WIDTH&#58; 160px
&#125;
#ipassword &#123;
   WIDTH&#58; 160px
&#125;
#ipassword2 &#123;
   WIDTH&#58; 160px
&#125;
.it3 &#123;
   VERTICAL-ALIGN&#58; top; WIDTH&#58; 160px
&#125;
.it1 &#123;   WIDTH&#58; 160px
&#125;
.Butt &#123;
   BORDER-RIGHT&#58; #2854a7 1px solid; BORDER-TOP&#58; #7cbaff 1px solid; FONT&#58; bold 12px Arial, Helvetica, sans-serif; BORDER-LEFT&#58; #7cbaff 1px solid; COLOR&#58; #ffffff; BORDER-BOTTOM&#58; #2854a7 1px solid; BACKGROUND-COLOR&#58; #3366cc
&#125;
</STYLE>
<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" bgcolor="#ffffff">
<DIV align="center">
<br />
<b>Eudemons Online Account Register</b>
<br />
<br />
<form method='post' action='register.php?act=register'>
      <TABLE width="312">
        <TBODY>
        <TR>
          <TD id=GoodStuff style="PADDING-LEFT&#58; 0px; MARGIN-LEFT&#58; 0px">
            <DIV id=theform style="PADDING-LEFT&#58; 0px">
            <TABLE class=fdata width="323" height="229">
              <TBODY>
              <TR>
                <TD class=Label align="right" height="32"><span style="font-size&#58; 9pt">UserID&#58;</span></TD>
                <TD class=it3 height="32">
            <INPUT class=it style="FONT-SIZE&#58; 9pt" name="id" id="id"><span style="font-size&#58; 9pt">
            </span></TR>
              <TR>
                <TD class=Label align="right" height="37"><span style="font-size&#58; 9pt">Password&#58;</span></TD>
                <TD class=it3 height="37">
            <INPUT class=it id="ipassword" style="FONT-SIZE&#58; 9pt" type=password maxLength=12 name=pass></TD>
                </TR>
              <TR>
                <TD class=Label align="right" height="32"><span style="font-size&#58; 9pt">Retype Password&#58;</span></TD>
                <TD class=it3 height="32">
            <input class=it1 id="ipassword" style="FONT-SIZE&#58; 9pt" type=password maxlength=12 name=retpass></TD>
                </TR>
              <TR>
                <TD class=Label align="right" height="32"><span style="font-size&#58; 9pt">Type Check Code&#58;</span></TD>
                <TD class=it3 height="32">
               <input name='CheckCode' size='20' maxlength='6'class=it style="FONT-SIZE&#58; 9pt"></TD>
                </TR>
              <TR>
                <TD height="25" align="right">Check Code&#58;</TD>
                <TD height="25"><span style="font-size&#58; 9pt"><img src='./inc/img.php' width='200' height='60' alt='Visual CAPTCHA'
  style='border&#58; 1px solid #000000; padding&#58; 2px;' /></TD></TR>
              <TR>
                <TD></TD>
                <TD style="FONT-SIZE&#58; 14px; VERTICAL-ALIGN&#58; middle">
            <span style="font-size&#58; 9pt"><input type="hidden" name="hash"><input class=Butt type=submit onClick="hash.value = login&#40;pass.value&#41;" value='Register' name=B1></span></TD>
                </TR></TBODY></TABLE>
            </DIV></TD></TR></TBODY></TABLE></FORM>
         <?php
         mysql_select_db&#40;$mydbacc&#41;;
         $res = mysql_query&#40;"SELECT count&#40;*&#41; FROM accounts;"&#41;;
         $val = mysql_fetch_array&#40;$res&#41;;
         echo "Total Accounts&#58; ".$val&#91;0&#93;."<br />";
         
         mysql_select_db&#40;$mydbdata&#41;;
         $res = mysql_query&#40;"SELECT count&#40;*&#41; FROM characters;"&#41;;
         $val = mysql_fetch_array&#40;$res&#41;;
         echo "Total Characters&#58; ".$val&#91;0&#93;."<br />";
         
         echo "Server Status&#58; ";
         $fp = @fsockopen&#40;$serveraddress, $serverport, $errno, $errstr, 1&#41;;
         if &#40;!$fp&#41; &#123;
            echo "<font style='color&#58; #FF3300'><B>Offline</B></font></br>";
         &#125;
         else
         &#123;
            echo "<font style='color&#58; #009933'><B>Online</B></font></br>";
            fclose&#40;$fp&#41;;
         &#125;
         ?>
         <center>
         <?php
         if&#40;$_GET&#91;'act'&#93; == "register"&#41;
         &#123;
            if&#40;PhpCaptcha&#58;&#58;Validate&#40;$_POST&#91;'CheckCode'&#93;&#41;&#41;
            &#123;
               mysql_select_db&#40;$mydbacc&#41;;
               $userid = trim&#40;$_POST&#91;'id'&#93;&#41;;
               $password=trim&#40;$_POST&#91;'pass'&#93;&#41;;
               $passretype=trim&#40;$_POST&#91;'retpass'&#93;&#41;;
               $hash=$_POST&#91;'hash'&#93;;
               if&#40;!ereg&#40;"^&#91;0-9a-z&#93;&#123;4,12&#125;$",$userid&#41;&#41;
               &#123;
                  echo "Only letters from \"a\" to \"z\" and numbers, lenght of 4 to 12 characters";
               &#125;
               else
               &#123;
                  if&#40;$password == $passretype&#41;
                  &#123;
                     if&#40;!ereg&#40;"^&#91;0-9a-zA-Z&#93;&#123;4,12&#125;$",$password&#41;&#41;
                     &#123;
                        echo "Only letters or numbers, lenght of 4 to 12 characters";
                     &#125;
                     else
                     &#123;
                        $res = mysql_query&#40;"select * from accounts where name = '".$userid."' order by id desc"&#41;;
                        if &#40;$res&#41;
                        &#123;
                           if&#40;mysql_num_rows&#40;$res&#41; == 0&#41;
                           &#123;
                              mysql_query&#40;"insert into accounts &#40;name,Password,Reg_date&#41; values &#40;'".$userid."','".$hash."','".date&#40;"y-m-d H&#58;i&#58;s", time&#40;&#41;&#41;."'&#41;"&#41;;
                              echo "Account registered successfully.";
                           &#125;
                           else
                           &#123;
                              echo "Account Already exists in database.";
                           &#125;
                         &#125;
                         else
                         &#123;
                            echo mysql_error&#40;&#41;."<br /><br />"."select * from accounts where name = '".$userid."' order by id desc";
                            die&#40;&#41;;
                         &#125;
                     &#125;
                  &#125;
                  else
                  &#123;
                     echo "Password not equal to Retyped Password.";
                  &#125;
               &#125;
            &#125;
            else
            &#123;
               echo "Check Code is Wrong";
            &#125;
         &#125;
         ?>
         </center>
      </DIV>
</body>
</html>


ke ta la8i poy bgazi

Κώδικας: Επιλογή όλων

Unknown column 'name' in 'where clause'

select * from accounts where name = 'dsdsds' order by id desc

Άβαταρ μέλους
soteres2002
S. & H. Moderator
Δημοσιεύσεις: 1524
Εγγραφή: 05 Μαρ 2004 22:17
Τοποθεσία: Ιωάννινα

mysql_num_rows

Δημοσίευση από soteres2002 » 21 Οκτ 2008 02:37

Ο SQL κώδικας που έχεις μέσα στο ΡΗΡ script είναι ευάλωτος σε injections. Πρέπει να κάνεις έλεγχο οτι η παράμετρος που περνάς στο SQL query είναι όντως string της μορφής που χρειάζεσαι στην εφαρμογή. Έτσι είναι πιθανό να σου σβήσουν εγγραφές ή ολόκληρα tables και ΒΔ που έχει η MySQL σου (ανάλογα με τα permissions του user που εκτελεί τα ερωτήματα), απλά τροποιώντας την τιμή της μεταβλητής ώστε να περιέχει κατάλληλο malicious SQL code.

xatzh
Δημοσιεύσεις: 15
Εγγραφή: 11 Αύγ 2007 16:15

mysql_num_rows

Δημοσίευση από xatzh » 21 Οκτ 2008 15:41

Κώδικας: Επιλογή όλων

Ο SQL κώδικας που έχεις μέσα στο ΡΗΡ script είναι ευάλωτος σε injections. Πρέπει να κάνεις έλεγχο οτι η παράμετρος που περνάς στο SQL query είναι όντως string της μορφής που χρειάζεσαι στην εφαρμογή. Έτσι είναι πιθανό να σου σβήσουν εγγραφές ή ολόκληρα tables και ΒΔ που έχει η MySQL σου &#40;ανάλογα με τα permissions του user που εκτελεί τα ερωτήματα&#41;, απλά τροποιώντας την τιμή της μεταβλητής ώστε να περιέχει κατάλληλο malicious SQL code.
De katalaba ti enois ime ligo asxetos ap to 8ema php
Telika katafera na to gtiakso na kani registrer ala re pedia de ta grafi sti mql ke de katalabeno to logo eno lei oti to ekane den to dimiourgi kanenas na gnorizi ti pezete na boi8isi 4 meres to palebo to 8ema.

Απάντηση

Επιστροφή στο “PHP Προγραμματισμός”

Μέλη σε σύνδεση

Μέλη σε αυτήν τη Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 0 επισκέπτες