Jump to content

[SOLVED] Headache of a problem =(


Steve Angelis

Recommended Posts

I know the answer is something very stupid... but I cannot figure this out:

 

<?PHP
$username=$_GET['username'];
$password=$_POST['password'];
$empire_name=$_POST['empire_name'];
$ruler_name=$_POST['ruler_name'];
$email2=$_POST['email'];
$description=$_POST['description'];

require('../inc/config.php'); 
$linkid = @mysql_connect("$db_host", "$db_uname", "$db_pass");
mysql_select_db("$db_name", $linkid);



$query = "SELECT * FROM nxg_member WHERE username='$username'";
$result = mysql_query($query) or die("$query does not make any sence;<br>" . mysql_error());
$name_exists = mysql_num_rows($result);
if ($name_exists == 0) 
{
$query2 = "SELECT * FROM nxg_member WHERE empire_name='$empire_name'";
$result2 = mysql_query($query2) or die("$query does not make any sence;<br>" . mysql_error());
$ename_exists = mysql_num_rows($result2);
if ($ename_exists == 0) 
{
$query3 = "SELECT * FROM nxg_member WHERE email='$email2'";
$result3 = mysql_query($query3) or die("$query does not make any sence;<br>" . mysql_error());
$email_exists = mysql_num_rows($result3);
if ($email_exists == 0) 
{

$totalChar = 7; // number of chars in the password
$salt = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ123456789";  // salt to select chars from
srand((double)microtime()*1000000); // start the random generator
$rndmpassword=""; // set the inital variable
for ($i=0;$i<$totalChar;$i++)  // loop and create password
            $rndmpassword = $rndmpassword . substr ($salt, rand() % strlen($salt), 1);
//input the shit to go into database here
echo "An email has been sent to <strong>".$email2."</strong> with a confirmation number.  Please follow the instructions provided to activate your account.<br />
<br />

";
echo $rndmpassword;


$to = $email;
$subject = "Welcome to Neraxia - The Game";
$body = "Welcome to Neraxia - The Game
/n/n Please go to the following link to activate your account at <a href='http://neraxia.com/game/activate.php?number=".$mbr_random_num."'>http://neraxia.com/game/activate.php?number=".$mbr_random_num."</a> :";
mysql_query("INSERT INTO nxg_tempmbr (id, username, password, empire_name, ruler_name, email, description, activate) values ('$username', '$password', '$empire_name', '$ruler_name', '$email', '$description', '$rndmpassword')") or die("$query does not make any sence;<br>" . mysql_error());
if (mail($to, $subject, $body)) {
  echo("<p>Message successfully sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}


}
else {
print "<br><br><font color=yellow>That E-Mail has already been used for a differant account.  Please hit the back button and select a differant one.</font>";}
}
else {
print "<br><br><font color=yellow>That empire name has already been taken.  Please hit the back button and select a differant one.</font>";
}
mysql_close($linkid);
} else {
print "<br><br><font color=yellow>That user name has already been taken.  Please hit the back button and select a differant one.</font>";
}
?>

 

The problem is with this part:

 

$query = "SELECT * FROM nxg_member WHERE username='$username'";
$result = mysql_query($query) or die("$query does not make any sence;<br>" . mysql_error());
$name_exists = mysql_num_rows($result);
if ($name_exists == 0) 
{
$query2 = "SELECT * FROM nxg_member WHERE empire_name='$empire_name'";
$result2 = mysql_query($query2) or die("$query does not make any sence;<br>" . mysql_error());
$ename_exists = mysql_num_rows($result2);
if ($ename_exists == 0) 
{
$query3 = "SELECT * FROM nxg_member WHERE email='$email2'";
$result3 = mysql_query($query3) or die("$query does not make any sence;<br>" . mysql_error());
$email_exists = mysql_num_rows($result3);
if ($email_exists == 0) 

 

I get this error:

 

SELECT * FROM nxg_member WHERE username='' does not make any sence;

Column count doesn't match value count at row 1

 

Before I was getting it with the email part, but since I named the query and result with numbers like 2 and 3, it went to username.  Does anyone see the problem with this?

Link to comment
Share on other sites

These come from a form on a differant page and I know they are being sent to this page, I have checked it with pervious code.

 

$username=$_GET['username'];

$password=$_POST['password'];

$empire_name=$_POST['empire_name'];

$ruler_name=$_POST['ruler_name'];

$email2=$_POST['email'];

$description=$_POST['description'];

 

Config.php connects to the DB and I know that it is connected, again, I tested it out with previous code.

Link to comment
Share on other sites

SELECT * FROM nxg_member WHERE username=''

Is that the actual error? If so sounds to me as somewhere the username isnt getting passed along..

 

When I have multiple queries I use trailing numbers and it works fine..

 

However I notice your hitting the same table 3 times over back to back with multiple queries, not that im saying this is the problem exactly, but assuming your pulling data from a particular row and its all data pertaing to that particular row.. or user.. why not query the table like

 

$query2 = "SELECT username, empire_name, email FROM nxg_member WHERE empire_name='$empire_name'";
$result2 = mysql_query($query2) or die("$query does not make any sence;<br>" . mysql_error());
$ename_exists = mysql_num_rows($result2);

 

try debugging also.. echo out ename_exists to see what its value is actually coming up with, or echo out all dynamicly generated variables when I run into similar problems.. as much as I don't want to do the extra coding to echo out the vars cause its more of a pain in the ass then anything else i know.. but when I break down and do it I save my self a trip to the store for aspirin.. try either or both see what you come up with, if your still having issues, deffinately come back one of us can hopefully help you

Link to comment
Share on other sites

You are most likely getting the error from this line:

<?php
mysql_query("INSERT INTO nxg_tempmbr (id, username, password, empire_name, ruler_name, email, description, activate) values ('$username', '$password', '$empire_name', '$ruler_name', '$email', '$description', '$rndmpassword')") or die("$query does not make any sence;<br>" . mysql_error());
?>

 

Since the "or die" clause references the first $query, not the current one. Change it to:

<?php
$q = "INSERT INTO nxg_tempmbr (id, username, password, empire_name, ruler_name, email, description, activate) values ('$username', '$password', '$empire_name', '$ruler_name', '$email', '$description', '$rndmpassword')";
mysql_query($q) or die("$q does not make any sense;<br>" . mysql_error());
?>

 

You will still get the error, since you have 8 fields and 7 values in the query.

 

Ken

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.