mus Posted August 4, 2011 Share Posted August 4, 2011 hi some people can help me i dont why im put this to my Hostmaster www.one.com but my if ($query) { header("[color=red]location:polish.php[/color]"); } is not work they will not header to my polish.php when im finished with my update in my database <? $raekke = $_POST['raekke']; $modelnr = $_POST['modelnr']; $navn = $_POST['navn']; $priser = $_POST['priser']; $display = $_POST['display']; $bruger = $_POST['bruger']; $salg = $_POST['salg']; $usedup = $_POST['usedup']; $instock = $_POST['instock']; $totaltstock = $_POST['totaltstock']; $username="usename"; // Mysql username $password="password"; // Mysql password mysql_connect ("hostt","$username", "$password") or die ("cannot connect"); mysql_select_db("database") or die ("cannot select DB"); $query="INSERT INTO opi(id, raekke, modelnr, navn, priser, display, bruger, salg, usedup, instock, totaltstock) VALUES ('NULL', '".$raekke."', '".$modelnr."','".$navn."', '".$priser."', '".$display."','".$bruger."','".$salg."','".$usedup."','".$instock."','".$totaltstock."')"; mysql_query($query) or die ('error updating databasen'); mysql_close($query); if ($query) { header("location:polish.php"); } ?> i want to when im finished they will header to my polish.php thanks Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 this: header("location:polish.php"); (like you have it in your bottom script) should work fine. the problem must be with if($query)... if the condition isn't met, your page will not redirect. I'm guessing you have some problem with the database connection or query. Quote Link to comment Share on other sites More sharing options...
mus Posted August 4, 2011 Author Share Posted August 4, 2011 i dont but i can update with my database, and when im finished to update, when i click to polish.php can i see they have put to in my database but i dont why they not header to polish.php they will be in this site Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 change these 3 lines: mysql_query($query) or die ('error updating databasen'); mysql_close($query); if ($query) to: $result = mysql_query($query) or die ('error updating databasen'); mysql_close(); if ($result) and try again Quote Link to comment Share on other sites More sharing options...
mus Posted August 4, 2011 Author Share Posted August 4, 2011 is not work i have try to changes this code $result = mysql_query($query) or die ('error updating databasen'); mysql_close($result); if ($result ) { header("location:polish.php"); } ?> Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 your database is called database? <? $raekke = $_POST['raekke']; $modelnr = $_POST['modelnr']; $navn = $_POST['navn']; $priser = $_POST['priser']; $display = $_POST['display']; $bruger = $_POST['bruger']; $salg = $_POST['salg']; $usedup = $_POST['usedup']; $instock = $_POST['instock']; $totaltstock = $_POST['totaltstock']; $username="usename"; // Mysql username $password="password"; // Mysql password $c = mysql_connect ("hostt","$username", "$password") or die ("cannot connect"); mysql_select_db("database",$c) or die ("cannot select DB"); $query="INSERT INTO `opi` (`raekke`, `modelnr`, `navn`, `priser`, `display`, `bruger`, `salg`, `usedup`, `instock`, `totaltstock`) VALUES ('$raekke','$modelnr','$navn','$priser','$display','$bruger','$salg','$usedup','$instock','$totaltstock')"; $result = mysql_query($query,$c) or die ('error updating databasen'); @mysql_close($c); if ($result){ header("location:polish.php"); } ?> Quote Link to comment Share on other sites More sharing options...
mus Posted August 4, 2011 Author Share Posted August 4, 2011 <? $raekke = $_POST['raekke']; $modelnr = $_POST['modelnr']; $navn = $_POST['navn']; $priser = $_POST['priser']; $display = $_POST['display']; $bruger = $_POST['bruger']; $salg = $_POST['salg']; $usedup = $_POST['usedup']; $instock = $_POST['instock']; $totaltstock = $_POST['totaltstock']; $username="usename"; // Mysql username $password="password"; // Mysql password mysql_connect ("Host name","$username", "$password") or die ("cannot connect"); mysql_select_db("polish") or die ("cannot select DB"); $query="INSERT INTO opi(id, raekke, modelnr, navn, priser, display, bruger, salg, usedup, instock, totaltstock) VALUES ('NULL', '".$raekke."', '".$modelnr."','".$navn."', '".$priser."', '".$display."','".$bruger."','".$salg."','".$usedup."','".$instock."','".$totaltstock."')"; $result = mysql_query($query) or die ('error updating databasen'); mysql_close($result); if ($result ) { header("location:polish.php"); ?> } Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 ???? mysql_connect ("THIS NEEDS TO BE YOUR HOST NAME","$username", "$password") or die ("cannot connect"); (probably 'localhost') mysql_select_db("THIS NEEDS TO BE YOUR DATABASE NAME",$c) or die ("cannot select DB"); Quote Link to comment Share on other sites More sharing options...
mus Posted August 4, 2011 Author Share Posted August 4, 2011 <? $raekke = $_POST['raekke']; $modelnr = $_POST['modelnr']; $navn = $_POST['navn']; $priser = $_POST['priser']; $display = $_POST['display']; $bruger = $_POST['bruger']; $salg = $_POST['salg']; $usedup = $_POST['usedup']; $instock = $_POST['instock']; $totaltstock = $_POST['totaltstock']; $username="User"; // Mysql username $password="PASS"; // Mysql password mysql_connect ("HOST NAME","$username", "$password") or die ("cannot connect"); mysql_select_db("DATABASE NAME") or die ("cannot select DB"); $query="INSERT INTO opi(id, raekke, modelnr, navn, priser, display, bruger, salg, usedup, instock, totaltstock) VALUES ('NULL', '".$raekke."', '".$modelnr."','".$navn."', '".$priser."', '".$display."','".$bruger."','".$salg."','".$usedup."','".$instock."','".$totaltstock."')"; $result = mysql_query($query) or die ('error updating databasen'); mysql_close($result); if ($result ) { header("location:polish.php"); } ?> Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 if you don't know your host name or your database name, i give up. Quote Link to comment Share on other sites More sharing options...
mus Posted August 4, 2011 Author Share Posted August 4, 2011 i have try this code but it not work. i dont why went i try in my location server this code work fine, when i finished to update in database they will jump back to my polish.php but went i upload to my hostmaster server they will not jump back to polish.php i dont why??? can some one help me thanks u Quote Link to comment Share on other sites More sharing options...
mus Posted August 4, 2011 Author Share Posted August 4, 2011 i now my hostname and my database hostname = 10.127.01.13 database = polish Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 post your database structure Quote Link to comment Share on other sites More sharing options...
mus Posted August 4, 2011 Author Share Posted August 4, 2011 here is my structore [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 can you print the whole page so I can see the table name and the database name (at the top and side) please? Quote Link to comment Share on other sites More sharing options...
mus Posted August 4, 2011 Author Share Posted August 4, 2011 her is me structore [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
WebStyles Posted August 4, 2011 Share Posted August 4, 2011 database is called "polish", and I expect your host is 'localhost'... Try this. Don't forget to change the username and password to access your database <?php $raekke = $_POST['raekke']; $modelnr = $_POST['modelnr']; $navn = $_POST['navn']; $priser = $_POST['priser']; $display = $_POST['display']; $bruger = $_POST['bruger']; $salg = $_POST['salg']; $usedup = $_POST['usedup']; $instock = $_POST['instock']; $totaltstock = $_POST['totaltstock']; $username="usename"; // Mysql username $password="password"; // Mysql password $c = mysql_connect ("localhost","$username", "$password") or die ("cannot connect"); mysql_select_db("polish",$c) or die ("cannot select DB"); $query="INSERT INTO `opi` (`raekke`, `modelnr`, `navn`, `priser`, `display`, `bruger`, `salg`, `usedup`, `instock`, `totaltstock`) VALUES ('$raekke','$modelnr','$navn','$priser','$display','$bruger','$salg','$usedup','$instock','$totaltstock')"; $result = mysql_query($query,$c) or die ('error updating databasen'); @mysql_close($c); if ($result){ header("location:polish.php"); } ?> Quote Link to comment Share on other sites More sharing options...
mus Posted August 4, 2011 Author Share Posted August 4, 2011 her [attachment deleted by admin] Quote Link to comment 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.