Thanks, its funny that it caused that. Anyway, i now have another error that I cant figure out because i know the syntax is right. But its providing an error as if its invalid.
Warning: mysql_fetch_arr ay(): supplied argument is not a valid MySQL result resource
I have this on two statements in my code...
[PHP]$check = mysql_query("SE LECT ethoId FROM member WHERE ethoId = '$ethoid'");
$returned = mysql_fetch_arr ay($check);
if(!empty($retu rned))
{
echo " This user already exists!";
mysql_close($me mber);
Die();
}
else
{
$check = mysql_query("SE LECT email FROM member WHERE emailId='$email '");
$returned = mysql_fetch_arr ay($check);
if(!empty($retu rned))
{
echo " This email already is with another account!";
mysql_close($me mber);
Die();
}[/PHP]
Try adding this after every mysql_query:
[code=php]
echo mysql_error();
[/code]
You might also want to save your sql into a variable so you can output that, too. E.g.:
[code=php]
$sql = "SELECT ethoId FROM member WHERE ethoId = '$ethoid'";
$check = mysql_query($sq l);
echo $sql, '<br />', mysql_error();
[/code]
Disregard that last post, i got that working. Now im stuck though. This problem is a bit harder. I set up an email confirmation script that should update a column in my database when they click the link in their email. However, i am having trouble finding the right record. I think i got the selecting of the column down but the update statement doesnt compute because the ID column is not a variable in the script. So the "where" part in the update statement doesnt work. This is the script, im just trying to update one column out of 15.
[PHP]$yes = "yes";
// Retrieve data from table where row that match this passkey
$sql1 = "SELECT confirm_code FROM member WHERE confirm_code ='$passkey'";
$result1 = mysql_query($sq l1);
if($result1){
// Count how many row has this passkey
$count=mysql_nu m_rows($result1 );
if($count==1){
$sql2 = "UPDATE member SET confirmed = '$yes' WHERE id = 'id'";
$result2 = mysql_query($sq l2);
echo $sql2, mysql_error();[/PHP]
I tried that and i see the problem just dont know how to tackle it. The issue seems that I have no variable to classify in the UPDATE line for id. I have an id column. But it doesnt update the confirmed column to a "yes" when the link is clicked. So i selected id from the table but how do i get into a variable that can be used in the update line so it knows which record im talking about? Because in its current form, if there was more than one record it would be a problem but its not even updating one record.
[PHP]$sql3 = "SELECT id FROM member WHERE confirm_code ='$passkey' limit 1";
$result1 = mysql_query($sq l3);
if($result1){
// Count how many row has this passkey
$count=mysql_nu m_rows($result1 );
if($count==1){
echo $sql3, '<br/>', mysql_error();
$sql4 = "UPDATE member SET confirmed = '$yes' WHERE id = '$sql3'";
$result2 = mysql_query($sq l4);
}[/PHP]
Ok, i have broken down the code step by step using the print_r and echo functions to have some kind of result print on the screen. While in the course of doing this i figured out that in the first part of the statement where it selects the records from the database, the resource id ends up always being 31. Obviously there is not 31 records in my database, its only one currently. so i think my problem is the actual selecting of the right ID and then to actually update a specific column in that row. So far ive just hit a nice large wall.
[PHP]$passkey=$_GET['passkey'];
$yes = "yes";
// Retrieve data from table where row that match this passkey
$sql3 = "SELECT id FROM member WHERE confirm_code ='$passkey'";
$result1 = mysql_query($sq l3);
$userdata = $result1;
if($result1){
$sql4 = "UPDATE member SET confirmed = '$yes' WHERE id = '$userdata'";
$result2 = mysql_query($sq l4);
print_r($sql4);
}
// if not found passkey, display message "Wrong Confirmation code"
else {
echo '<div class="error"> Wrong Confirmation Code!! </div>';
}
if($result2){
echo '<div class="error"> Your account has been confirmed.<br/>Welcome to <br/><strong>Etho s</strong>!!</div>';
mysql_close($me mber);
Die();
}[/PHP]
Ok since i last posted i have done very well in my php coding but now im kinda stuck again. But this time more in phpMyAdmin. Does anyone know how to link tables in that program because is surely cant find an option for it?
Ok since i last posted i have done very well in my php coding but now im kinda stuck again. But this time more in phpMyAdmin. Does anyone know how to link tables in that program because is surely cant find an option for it?
Link Table in PhpMyAdmin? Could you please be more specific?
Comment