Member Avatar for megachip04

this is the code to email confirm. The user clicks on the link in the email, passing the code through url to this page. Then the data is transferred from a tmp table to main one.

I have queried in phpmyadmin and it works fine. But when i actually use the php i get the "else {echo "error";}" suggesting that the INSERT query is not working. Any suggestions?

include("db_config_db.php");

$code=$_GET['code'];

$sql1="SELECT * FROM table1 WHERE code ='$code'";
$result1=mysql_query($sql1);

if($result1){
$count=mysql_num_rows($result1);

if($count==1){

while($rows=mysql_fetch_array($result1)){
$username = $rows['username'];
$name = $rows['name'];
$email = $rows['email'];
$address = $rows['address'];
$city = $rows['city'];
$state = $rows['state'];
$zip = $rows['zip'];
$phone = $rows['phone'];
$birthday = $rows['birthday'];
$country = $rows['country'];
$description = $rows['description'];
$keywords = $rows['keywords'];
$setup = $rows['setup'];
}

$sql2="INSERT INTO table2 (name, email, address, city, state, zip, phone, birthday, country, description, username, code, keywords, setup)VALUES('$name', '$email', '$address', '$city', '$state', '$zip', '$phone', '$birthday', '$country', '$description', '$username', '$code', '$keywords', '$setup')";
$result2=mysql_query($sql2);

if($result2){
$sql3="DELETE FROM table1 WHERE code = '$code'";
$result3=mysql_query($sql3);
header("location:index.php");
}
else{ echo "error";
}
}
else {
echo "Wrong Confirmation code";
}
}

Recommended Answers

All 8 Replies

Snip im an idiot.. nvm lol

Member Avatar for megachip04

Not completely sure what you mean, but yes, mysql typically works. The first SELECT is working, but the INSERT INTO is not.

Post ur html file from where u send the info......

do use die function every mysql statement such as
mysql_query("select * from fdf) or die("not working1");
u can able to detect which function is not working....
Tell me if u find any error

commented: good +6

$username = $rows;
$name = $rows;
$email = $rows;
$address = $rows;
$city = $rows;
$state = $rows;
$zip = $rows;
$phone = $rows;
$birthday = $rows;
$country = $rows;
$description = $rows;
$keywords = $rows;
$setup = $rows;
}

make sure ur html textboxes names is same as ur given index name

ex.
$setup = $rows; = <input type=text name="setup">

Member Avatar for megachip04

i'm not posting to the page through the form. I'm selecting them from the database

Tell me the error you get while parsing in php?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.