cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PHP script not posting to database

Hi all,

 

Hopefully someone has some experience with this.

 

I recently moved to go daddy from another web host. On the old host the webform I have would post data to the database without any issues. Because it was a relatively new site I didn't bother migrating it, I just created the databases and users on godaddy with the exact same names and expected the form would post data to the new database without any changes to the code (it worked before so why wouldn't it still work now right?)

 

So when I now submit the form on the godaddy hosted site it does not insert the data into the database (keeping in mind I made no changes to the code on the pages and named the MySQL users and databases the same as on the other host).

 

Looking at the error log, it returns the following. Does anyone have any experience with this error and/or any advice on what I might be able to change to get the data to start posting into the database correctly?:

 

[23-Oct-2017 21:15:01 UTC] PHP Warning:  mysqli_select_db() expects parameter 1 to be mysqli, string given in /home/hockeypool123/public_html/script.php on line 23
[23-Oct-2017 21:15:01 UTC] PHP Notice:  Undefined index: game2 in /home/hockeypool123/public_html/script.php on line 26
[23-Oct-2017 21:15:01 UTC] PHP Notice:  Undefined index: game3 in /home/hockeypool123/public_html/script.php on line 27
[23-Oct-2017 21:15:01 UTC] PHP Notice:  Undefined index: game4 in /home/hockeypool123/public_html/script.php on line 28
[23-Oct-2017 21:15:01 UTC] PHP Notice:  Undefined index: game5 in /home/hockeypool123/public_html/script.php on line 29
[23-Oct-2017 21:15:01 UTC] PHP Notice:  Undefined index: game6 in /home/hockeypool123/public_html/script.php on line 30
[23-Oct-2017 21:15:01 UTC] PHP Notice:  Undefined index: game7 in /home/hockeypool123/public_html/script.php on line 31
[23-Oct-2017 21:15:01 UTC] PHP Notice:  Undefined index: game8 in /home/hockeypool123/public_html/script.php on line 32
[23-Oct-2017 21:15:01 UTC] PHP Notice:  Undefined index: game9 in /home/hockeypool123/public_html/script.php on line 33
[23-Oct-2017 21:15:01 UTC] PHP Notice:  Undefined index: game10 in /home/hockeypool123/public_html/script.php on line 34
[23-Oct-2017 21:15:01 UTC] PHP Notice:  Undefined index: game11 in /home/hockeypool123/public_html/script.php on line 35
[23-Oct-2017 21:15:01 UTC] PHP Notice:  Undefined index: game12 in /home/hockeypool123/public_html/script.php on line 36
[23-Oct-2017 21:15:01 UTC] PHP Notice:  Undefined index: game13 in /home/hockeypool123/public_html/script.php on line 37
[23-Oct-2017 21:15:01 UTC] PHP Notice:  Undefined index: game14 in /home/hockeypool123/public_html/script.php on line 38
[23-Oct-2017 21:15:01 UTC] PHP Notice:  Undefined index: game15 in /home/hockeypool123/public_html/script.php on line 39
[23-Oct-2017 21:15:01 UTC] PHP Warning:  mysqli_query() expects at least 2 parameters, 1 given in /home/hockeypool123/public_html/script.php on line 50
4 REPLIES 4
Helper V

Re: PHP script not posting to database

@moose831

 

Hi there,

Looks like the script is wrong for this server...... what have you tried and lets get this going. Dont add any personal info, fake info 😉

It could be something really stupid too such as : instead of a ; .....

Mrsroadrunner Photography

Re: PHP script not posting to database

@mrsroadrunner

 

So here is the PHP script I had before (apologies if its crude, I self taught online and have no previous experience in php or web coding in general) 

 

<?
if( $_POST )
{
  $con = mysqli_connect("localhost","xxx","xxx");

  if (!$con)
  {
    die('Could not connect: ' . mysqli_error());
  }

  mysqli_select_db("xxx", $con);

  $game1 = $_POST['game1'];
  $game2 = $_POST['game2'];
  $game3 = $_POST['game3'];
  $game4 = $_POST['game4'];
  $game5 = $_POST['game5'];
  $game6 = $_POST['game6'];
  $game7 = $_POST['game7'];
  $game8 = $_POST['game8'];
  $game9 = $_POST['game9'];
  $game10 = $_POST['game10'];
  $game11 = $_POST['game11'];
  $game12 = $_POST['game12'];
  $game13 = $_POST['game13'];
  $game14 = $_POST['game14'];
  $game15 = $_POST['game15'];
  $name = $_POST['name'];
  $email = $_POST['email'];
  $articleid = $_POST['articleid'];
 
$query = "
  INSERT INTO `picks` (`id`, `game1`, `game2`, `game3`, `game4`, `game5`,
  `game6`, `game7`, `game8`, `game9`, `game10`,
  `game11`, `game12`, `game13`, `game14`, `game15`, `name`, `timestamp`, `articleid`)
  VALUES (NULL, '$game1', '$game2', '$game3', '$game4', '$game5', '$game6', '$game7', '$game8', '$game9', '$game10', '$game11', '$game12', '$game13', '$game14', '$game15', '$name', CURRENT_TIMESTAMP, '$articleid');";

  mysqli_query($query);

  mysqli_close($con);
}
?>

Helper V

Re: PHP script not posting to database

@moose831

Hi there 🙂 omg dont worry about the small stuff, many of us have been self taught!

Ok one dude he fixed his issues by ... well here is what he said, "I fixed it by changing my php installation from CGI binary to the ISAPI module".

------------------

Something that might be super stupid and i feel foolish for even saying this..... in your .htaccess file, what is your php_value post_max_size set as?? could it need to be higher??

 

I jumped into wordpress when I noticed a error with the $_POST (I think if I had to use $_REQUEST) , this is not wordpress you are working with right??

 

All the ideas i have for now - hopefully this helped if not just a little .......

 

Mrsroadrunner Photography
3fk
Former Employee

Re: PHP script not posting to database

Try changing php versions,
Toggle it.

Try uploading phpinfo.php to see php specs.

Upload /.user.ini or php.ini   with codes in it.

like: 

memory_limit = 256M
upload_max_filesize = 1000M
post_max_size = 256M
file_uploads = On
max_execution_time = 1500


What else.