Jump to content

Recommended Posts

<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
[!--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?
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.
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]
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:(
[!--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?)
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 16
on line 16 is $db=new mysqli('host,'championships','passwd','championships');
it stucks here.if i echoed anything after it still dosen`t show.
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]
[!--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 16
on 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() ...
[!--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)
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.