Iryk Posted December 13, 2006 Share Posted December 13, 2006 I have a form on a different page and I am getting no errors on this page (install_process.php). But the information that I entered in the form is not being entered into the database... Can some one please tell me what I have done wrong?[code]<?php $db_username = $_POST['db_username']; $db_password = $_POST['db_password']; $db_host = $_POST['db_host']; $connect = 'mysql_connect($db_host,$db_username,$db_password)'; if(empty($connect)) { echo "<center><span style='color: red; font: 8pt verdana'>Database information is wrong. Please go back and retype the information.</span></center>"; } else { if ($your_password != $retype_password) { echo "<center><span style='color: red; font: 8pt verdana'>Your passwords do not match. Please go back and retype the information.</span></center>"; } else { $dat = date("D j M, Y"); $title = $_POST['site_title']; $description = $_POST['site_description']; $copyright = $_POST['site_copyright']; $url = $_POST['site_url']; $banner = $_POST['site_banner']; $username = $_POST['your_username']; $password = md5($_POST['your_password']); $location = $_POST['your_location']; $email = $_POST['your_email']; $avatar = $_POST['your_avatar']; $website = $_POST['your_website']; $signature = $_POST['your_signature']; $installed = '$installed'; $new_content = "<? " . $installed . " = 'yes'; mysql_connect('" . $db_host . "','" . $db_username . "','" . $db_password . "'); ?>"; $file = fopen('../db_connect.php', 'a'); fwrite($file,$new_content); fclose($file); include("../db_connect.php"); mysql_query("INSERT INTO user (user, pass, website, email, avatar, location, sig) VALUES ('$username','$password', '$website', '$email', '$avatar','$location','$signature')"); mysql_query("INSERT INTO staff VALUES ('$username','Admin','0')"); mysql_query("INSERT INTO site VALUES ('$title','$description','$dat','Blue','$copyright','$url','$banner')"); echo '<center><span style="color:green;font-size:8pt;font-family: verdana">The installation was successful.</span><br><a href="../index.php"><span style="font-size:8pt;font-family: verdana">Go to the homepage</span></a></center>'; } }?>[/code] Link to comment https://forums.phpfreaks.com/topic/30567-information-isnt-being-entered-into-database/ Share on other sites More sharing options...
hitman6003 Posted December 13, 2006 Share Posted December 13, 2006 Why is your mysql_connect inside of single quotes?[code]$connect = 'mysql_connect($db_host,$db_username,$db_password)';[/code] Link to comment https://forums.phpfreaks.com/topic/30567-information-isnt-being-entered-into-database/#findComment-140733 Share on other sites More sharing options...
Iryk Posted December 13, 2006 Author Share Posted December 13, 2006 I have no idea... lol... i took the single quotes out and nothing changed. Link to comment https://forums.phpfreaks.com/topic/30567-information-isnt-being-entered-into-database/#findComment-140735 Share on other sites More sharing options...
Iryk Posted December 14, 2006 Author Share Posted December 14, 2006 I have rewritten my code partially...[code]<?php $db_username = $_POST['db_username']; $db_password = $_POST['db_password']; $db_host = $_POST['db_host']; $connect = mysql_connect("$db_host","$db_username","$db_password") or die("<center><span style='color: red; font: 8pt verdana'>Database information is wrong. Please go back and retype the information.</span></center>"); if ($your_password != $retype_password) { echo "<center><span style='color: red; font: 8pt verdana'>Your passwords do not match. Please go back and retype the information.</span></center>"; } else { $dat = date("D j M, Y"); $title = $_POST['site_title']; $description = $_POST['site_description']; $copyright = $_POST['site_copyright']; $url = $_POST['site_url']; $banner = $_POST['site_banner']; $username = $_POST['your_username']; $password = md5($_POST['your_password']); $location = $_POST['your_location']; $email = $_POST['your_email']; $avatar = $_POST['your_avatar']; $website = $_POST['your_website']; $signature = $_POST['your_signature']; $installed = '$installed'; $new_content = "<? " . $installed . " = 'yes'; mysql_connect('" . $db_host . "','" . $db_username . "','" . $db_password . "'); ?>"; $file = fopen('../db_connect.php', 'a'); fwrite($file,$new_content); fclose($file); include("../db_connect.php"); mysql_query("INSERT INTO user (user, pass, website, email, avatar, location, sig) VALUES ('$username','$password', '$website', '$email', '$avatar','$location','$signature')"); mysql_query("INSERT INTO staff VALUES ('$username','Admin','0')"); mysql_query("INSERT INTO site VALUES ('$title','$description','$dat','Blue','$copyright','$url','$banner')"); echo '<center><span style="color:green;font-size:8pt;font-family: verdana">The installation was successful.</span><br><a href="../index.php"><span style="font-size:8pt;font-family: verdana">Go to the homepage</span></a></center>'; }?>[/code] Link to comment https://forums.phpfreaks.com/topic/30567-information-isnt-being-entered-into-database/#findComment-140762 Share on other sites More sharing options...
matto Posted December 14, 2006 Share Posted December 14, 2006 where is your mysql_select_db() ? Link to comment https://forums.phpfreaks.com/topic/30567-information-isnt-being-entered-into-database/#findComment-140853 Share on other sites More sharing options...
btherl Posted December 14, 2006 Share Posted December 14, 2006 If you don't check for errors then you won't get any :)Add [code=php:0] or die("Error: " . mysql_error());[/code] after each mysql_query(), and it'll tell you if those queries are failing.eg[code=php:0]mysql_query("INSERT INTO staff VALUES ('$username','Admin','0')") or die("Error: " . mysql_error());[/code] Link to comment https://forums.phpfreaks.com/topic/30567-information-isnt-being-entered-into-database/#findComment-140857 Share on other sites More sharing options...
swatisonee Posted December 14, 2006 Share Posted December 14, 2006 Where is your db name out here ??$db_username = $_POST['db_username']; $db_password = $_POST['db_password']; $db_host = $_POST['db_host']; Link to comment https://forums.phpfreaks.com/topic/30567-information-isnt-being-entered-into-database/#findComment-140867 Share on other sites More sharing options...
Iryk Posted December 14, 2006 Author Share Posted December 14, 2006 i got it fixed. Thanks for your guys' help ;) Link to comment https://forums.phpfreaks.com/topic/30567-information-isnt-being-entered-into-database/#findComment-140875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.