Jump to content

Recommended Posts

I first created it on my computer and tested it locally and everything worked but now I have uploaded it to a webserver and changed everything according to what I need to like the connection and password. those required details in mysql_connect("host","user","password") that has been changed to what they should be but it won't allow me to add data from input fields in the data base.

 

It does not give an error or anything just a blank say example I have this html form

<form action="test.php" enctype="multipart/form-data" method="post">

<input type="text" name="datatoAdd">

<input type="submit">

</form>

 

 

and on the page test.php I have

 

 

$con = mysql_connect("host","user","password");

 

mysql_select_db("database", $con);

 

mysql_query("INSERT INTO table (fields) VALUES ('values')");

 

mysql_close($con);

 

then there is no data added to the database I also checked if it actually connects it does.

 

I also can't view data that I manually added to the table with phpMyAdmin.

Link to comment
https://forums.phpfreaks.com/topic/222004-does-not-insert-data-into-table/
Share on other sites

Make sure PHP errors are turned on and change your code to:

$con = mysql_connect("host","user","password") or die(mysql_error());

mysql_select_db("database", $con) or die(mysql_error());

mysql_query("INSERT INTO table (fields) VALUES ('values')") or die(mysql_error());

And then let us know what the errors are. At glance, it looks like multiple things are wrong, so we gotta go through them one by one.

Ok Let me give you the code I use I only copied the sql part the others are just declaring the variables. but this as it is here work when I test it offline on the server I have on my computer but not on the webserver I use.

 

$con = mysql_connect("host","user","password");if (!$con)

{

echo "The server is currently down try again later!";

}

mysql_select_db("database", $con);

$cExists = mysql_query("SELECT * FROM club");

//Here I check if the given data is not yet entered in the table

$Continue = true;

 

while ($row = mysql_fetch_array($cExists))

{

if (strtolower($row["cName"]) == strtolower($cName))

{

$Continue = false;

break;

}

}

mysql_close($con);

//Here it adds the data if the given data does not exists

if ($Continue == false)

{

incomplete();

}

else if ($Continue == true)

{

$con = mysql_connect("host","user","password");if (!$con)

{

echo "The server is currently down try again later!";

}

mysql_select_db("database", $con);

 

mysql_query("INSERT INTO club (mName, mEmail, mNumber, Password, cName, cNumber, cType, cCity, cSuburb, cStreet, cGPS) VALUES ('". $mName ."', '". $mEmail ."', '". $mNumber ."', '". $mPassword ."', '". $cName ."', '". $cNumber ."', '". $cType ."', '". $cCity ."', '". $cSuburb ."', '". $cStreet ."', '". $cGPS ."')");

 

mysql_close($con);

}

 

 

I do not know can it be file permissions that need to be set?

 

Here is the website check it out then you will see what I mean.

www.wheretoclub.co.cc/list.php

Try and list something then to login in it does not want you to.

Hello again my script now adds the data but I have a problem with the login part here is the script but what it does it just "skips" a part

 

<?php
   //echo $_POST["cName"];
   $con = mysql_connect("host","user","password");
   if(!mysql_select_db("database", $con))
   {
      echo mysql_error();
   }

   $cDetails = mysql_query("SELECT * FROM club WHERE cName = \"". $_POST["cName"] ."\" ");
   
   while($row = mysql_fetch_array($cDetails))
   {
                          //Here it seems to skip or something eventhough the data entered that needs no be checked is correct!
      if ($row['Password'] == $_POST["mPassword"])
      {
         setcookie("user",$_POST["cName"],time()+3600);
         echo "<script type='text/javascript' language='javascript'> location.replace('manage.php'); </script>";
      }
                         //Even if I enter the correct data it keeps on doing this part!
      else
      {
         echo "<script type='text/javascript' language='javascript'> alert('You have entered incorrect details!'); location.replace('login.php'); </script>";
      }
   }
   mysql_close($con);
?>

 

Mod edit:

 . . . 

tags added.

Hello again my script now adds the data

Great! What was wrong?

 

I have a problem with the login part here is the script but what it does it just "skips" a part

Which part does it skip? What data are you inputting and what is the expected result?

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.