Steve Angelis Posted February 3, 2008 Share Posted February 3, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/89168-solved-headache-of-a-problem/ Share on other sites More sharing options...
ratcateme Posted February 3, 2008 Share Posted February 3, 2008 what values are being set in require('../inc/config.php'); is there a $username value Scott. Quote Link to comment https://forums.phpfreaks.com/topic/89168-solved-headache-of-a-problem/#findComment-456602 Share on other sites More sharing options...
Steve Angelis Posted February 3, 2008 Author Share Posted February 3, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/89168-solved-headache-of-a-problem/#findComment-456603 Share on other sites More sharing options...
monkeytooth Posted February 3, 2008 Share Posted February 3, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/89168-solved-headache-of-a-problem/#findComment-456608 Share on other sites More sharing options...
budimir Posted February 3, 2008 Share Posted February 3, 2008 Try this $query = "SELECT * FROM nxg_member WHERE username='$_GET['username']'"; Quote Link to comment https://forums.phpfreaks.com/topic/89168-solved-headache-of-a-problem/#findComment-456647 Share on other sites More sharing options...
kenrbnsn Posted February 3, 2008 Share Posted February 3, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/89168-solved-headache-of-a-problem/#findComment-456697 Share on other sites More sharing options...
Steve Angelis Posted February 3, 2008 Author Share Posted February 3, 2008 Ok that all got it thanx Quote Link to comment https://forums.phpfreaks.com/topic/89168-solved-headache-of-a-problem/#findComment-456948 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.