alarik149 Posted March 6, 2006 Share Posted March 6, 2006 <html><head></head><body><?php$username=$_POST['username'];$status=$_POST['status'];if(!$status || !$username) echo "enter data";if(get_magic_quotes_gpc()) { $username=addslashes($username); $status=addslashes($status);}@ $db=new mysqli('host','championships','passwd','championships');if(mysqli_connect_errno()) { echo "could not connect"; }$query="insert into register values ('".$username."','".$username."','".$status."')";$result=$db->query($query);if($result) { echo "success !"; }$db->close();?></body></html>that is the script.i get $username and $status from an external html script,that is not the problem.the problem is here.let`s consider the connection to the databse is done good,,what can be the problem?i get no errors,just a blank page when the script runs and no information is added 2 the database.the database name is championships and the table name is register.HELP GUYS:( PLEASE Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/ Share on other sites More sharing options...
XenoPhage Posted March 6, 2006 Share Posted March 6, 2006 [!--quoteo(post=352231:date=Mar 6 2006, 04:34 PM:name=ADRlAN)--][div class=\'quotetop\']QUOTE(ADRlAN @ Mar 6 2006, 04:34 PM) [snapback]352231[/snapback][/div][div class=\'quotemain\'][!--quotec--]$query="insert into register values ('".$username."','".$username."','".$status."')";that is the script.i get $username and $status from an external html script,that is not the problem.the problem is here.let`s consider the connection to the databse is done good,,what can be the problem?i get no errors,just a blank page when the script runs and no information is added 2 the database.the database name is championships and the table name is register.HELP GUYS:( PLEASE[/quote]Well, your logic says not to print anything if there's a problem.. :)Try adding a print statement and take a look at the query.. Maybe there's a query problem? Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14793 Share on other sites More sharing options...
php_b34st Posted March 6, 2006 Share Posted March 6, 2006 You have put dbl quotations in unecessary places try:[code]<html><head></head><body><?php$username=$_POST['username'];$status=$_POST['status'];if(!$status || !$username) echo "enter data";if(get_magic_quotes_gpc()) {$username=addslashes($username);$status=addslashes($status);}@ $db=new mysqli('host','championships','passwd','championships');if(mysqli_connect_errno()) { echo "could not connect"; }$query="insert into register values ('$username','$username','$status')";$result=$db->query($query);if($result) { echo "success !"; }$db->close();?></body></html>[/code]Also did you know you are entering the username into the db twice? I dont know if you have two rows or if this is a mistake. Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14794 Share on other sites More sharing options...
Gaia Posted March 6, 2006 Share Posted March 6, 2006 Also try adding in mysql_error();[code]if ($result) { echo 'Success';} else { die(mysql_error());}[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14796 Share on other sites More sharing options...
alarik149 Posted March 6, 2006 Author Share Posted March 6, 2006 i know i`m entering it 2 times...and the values from the html for $username and $status are coming good...something else is the problem:( Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14800 Share on other sites More sharing options...
php_b34st Posted March 6, 2006 Share Posted March 6, 2006 There is no need for that code he has already put that in:[code]@ $db=new mysqli('host','championships','passwd','championships');if(mysqli_connect_errno()) { echo "could not connect"; }$query="insert into register values ('".$username."','".$username."','".$status."')";$result=$db->query($query);if($result) { echo "success !"; }[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14801 Share on other sites More sharing options...
Gaia Posted March 6, 2006 Share Posted March 6, 2006 He just has it so that when the database does not connect it will display an error, not when the query is ran..unless i'm missing something. Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14803 Share on other sites More sharing options...
php_b34st Posted March 6, 2006 Share Posted March 6, 2006 Did You try removing the double qoutations so yr sql now looks like:[code]$query="insert into register values ('$username','$username','$status')";[/code]Ah yes so he has, my mistake Gaia Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14804 Share on other sites More sharing options...
alarik149 Posted March 6, 2006 Author Share Posted March 6, 2006 i`ve added if ($result) { echo 'Success';} else { die(mysql_error());}still i don`t get anything,no success nor nothing.if I echo anything after@ $db=new mysqli(host','championships','passwd','championships');it dosen`t appear,if I echoed anywhere before that statement it works.something is here I think:(guys tell me the exact way to make another connection:( Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14812 Share on other sites More sharing options...
XenoPhage Posted March 6, 2006 Share Posted March 6, 2006 [!--quoteo(post=352257:date=Mar 6 2006, 05:01 PM:name=ADRlAN)--][div class=\'quotetop\']QUOTE(ADRlAN @ Mar 6 2006, 05:01 PM) [snapback]352257[/snapback][/div][div class=\'quotemain\'][!--quotec--]still i don`t get anything,no success nor nothing.if I echo anything after@ $db=new mysqli(host','championships','passwd','championships');it dosen`t appear,if I echoed anywhere before that statement it works.something is here I think:(guys tell me the exact way to make another connection:([/quote]Check your error log... I'm betting that @ symbol has something to do with it.. (Why is it there?) Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14818 Share on other sites More sharing options...
Gaia Posted March 6, 2006 Share Posted March 6, 2006 It could also be something wrong with your $db->query class, unless you've successfully ran queries with this script before. Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14819 Share on other sites More sharing options...
alarik149 Posted March 6, 2006 Author Share Posted March 6, 2006 I removed the @ and i run the script and i get this error :Fatal error: Cannot instantiate non-existent class: mysqli in /home/content/n/o/l/nolimit3/html/register.php on line 16on line 16 is $db=new mysqli('host,'championships','passwd','championships');it stucks here.if i echoed anything after it still dosen`t show. Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14822 Share on other sites More sharing options...
php_b34st Posted March 6, 2006 Share Posted March 6, 2006 are you running php5? do you have mysqli enabled? Here is an alternative way of connecting to the db:[code]//Create short variable names$host = 'host';$db_username = 'username';$db_password = 'password;$database = 'database';//Create connection$connection = mysql_pconnect("$host","$db_username","$db_password") or die ("Couldn't connect to server.");//Select database$db = mysql_select_db("$database", $connection) or die("Couldn't select database.");[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14827 Share on other sites More sharing options...
XenoPhage Posted March 6, 2006 Share Posted March 6, 2006 [!--quoteo(post=352267:date=Mar 6 2006, 05:09 PM:name=ADRlAN)--][div class=\'quotetop\']QUOTE(ADRlAN @ Mar 6 2006, 05:09 PM) [snapback]352267[/snapback][/div][div class=\'quotemain\'][!--quotec--]I removed the @ and i run the script and i get this error :Fatal error: Cannot instantiate non-existent class: mysqli in /home/content/n/o/l/nolimit3/html/register.php on line 16on line 16 is $db=new mysqli('host,'championships','passwd','championships');it stucks here.if i echoed anything after it still dosen`t show.[/quote]Do you have PHP 5 ? Sounds like whatever version you do have doesn't support mysqli() ... Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14828 Share on other sites More sharing options...
alarik149 Posted March 6, 2006 Author Share Posted March 6, 2006 yes it`s 5 :(how can i bypass mysqli() ? Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14833 Share on other sites More sharing options...
php_b34st Posted March 6, 2006 Share Posted March 6, 2006 You could either enable mysqli() in your php.ini (it is disabled by default) by removing the colon in front if it. or try connecting using the method i posted earlier. Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14839 Share on other sites More sharing options...
XenoPhage Posted March 6, 2006 Share Posted March 6, 2006 [!--quoteo(post=352284:date=Mar 6 2006, 05:22 PM:name=php_b34st)--][div class=\'quotetop\']QUOTE(php_b34st @ Mar 6 2006, 05:22 PM) [snapback]352284[/snapback][/div][div class=\'quotemain\'][!--quotec--]You could either enable mysqli() in your php.ini (it is disabled by default) by removing the colon in front if it. or try connecting using the method i posted earlier.[/quote]Make sure you restart apache after editing php.ini... (assuming you're using apache) Quote Link to comment https://forums.phpfreaks.com/topic/4256-what-is-wrong-with-this-script-pls-tell-me/#findComment-14841 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.