GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech Why wont this let me add more than 1 record? (https://gfy.com/showthread.php?t=1351948)

Publisher Bucks 02-03-2022 11:01 AM

Why wont this let me add more than 1 record?
 
So I have the basic CRUD setup but when it comes to adding a new domain (or several records) it will allow me to add the first record (ID=0) in the database, but then wont let me add anything additional, can anyone tell me why? :helpme

Quote:

<html>
<head>
<base href="https://gfy.com/" /><!--[if IE]></base><![endif]-->
<title>Add Domain</title>
</head>

<body>
<a href="index.php">Go to Home</a>
<br/><br/>

<form action="add.php" method="post" name="form1">
<table width="25%" border="0">
<tr>
<td>Registrar</td>
<td><input type="text" name="Registrar"></td>
</tr>
<tr>
<td>Domain</td>
<td><input type="text" name="DomainName"></td>
</tr>
<tr>
<td>Registered</td>
<td><input type="text" name="Registration"></td>
</tr>
<tr>
<td>Expires</td>
<td><input type="text" name="Expiration"></td>
</tr>
<tr>
<td>NS1</td>
<td><input type="text" name="NameServer1"></td>
</tr>
<tr>
<td>NS2</td>
<td><input type="text" name="NameServer2"></td>
</tr>
<tr>
<td>Status</td>
<td><input type="text" name="Status"></td>
</tr>
<tr>
<td>Notes</td>
<td><input type="text" name="Notes"></td>
</tr>
<tr>

<td></td>
<td><input type="submit" name="Submit" value="Add"></td>
</tr>
</table>
</form>

<?php

// Check If form submitted, insert form data into table.
if(isset($_POST['Submit'])) {


$Registrar=$_POST['Registrar'];
$DomainName=$_POST['DomainName'];
$Registration=$_POST['Registration'];
$Expiration=$_POST['Expiration'];
$NameServer1=$_POST['NameServer1'];
$NameServer2=$_POST['NameServer2'];
$Status=$_POST['Status'];
$Notes=$_POST['Notes'];

// include database connection file
include_once("config.php");

// Insert user data into table
$result = mysqli_query($mysqli, "INSERT INTO DomainManagement(Registrar,DomainName,Registration ,Expiration,NameServer1,NameServer2,Status,Notes) VALUES('$Registrar','$DomainName','$Registration', '$Expiration','$NameServer1','$NameServer2','$Stat us','$Notes')");

// Show message when user added
echo "Record added successfully. <a href='index.php'>View Users</a>";
}
?>
</body>
</html>
Been playing with this a few hours trying to figure out why and its driving me crazy, it isnt kicking out any errors, just isnt entering data into the table :(

sarettah 02-03-2022 11:13 AM

Quote:

Originally Posted by Publisher Bucks (Post 22961362)
So I have the basic CRUD setup but when it comes to adding a new domain (or several records) it will allow me to add the first record (ID=0) in the database, but then wont let me add anything additional, can anyone tell me why? :helpme



Been playing with this a few hours trying to figure out why and its driving me crazy, it isnt kicking out any errors, just isnt entering data into the table :(

Without knowing more about the table you are inserting into, it is hard to say. Could be duplicate entry on a unique index, not sure. Also not sure what level you are reporting errors. When I am in development mode I have all error reporting php and mysql turned on so I can see anything that goes wrong. I also put message s in the code so I can see exactly what is happening and when.

However, in what you posted, if it is the code that you are running there is a space in '$status' that should not be there, but that should blow it off every time not just on subsequent runs.

Quote:

$result = mysqli_query($mysqli, "INSERT INTO DomainManagement(Registrar,DomainName,Registration ,Expiration,NameServer1,NameServer2,Status,Notes) VALUES('$Registrar','$DomainName','$Registration', '$Expiration','$NameServer1','$NameServer2','$Stat us','$Notes')");

Publisher Bucks 02-03-2022 12:55 PM

Thanks.

That 'Status' one just seems to be on GFY, its not on the server version, must have just been a FF issue.

Would you possibly be able to share the php code that I can use to check MySQL for errors? :D

Klen 02-03-2022 02:38 PM

Quote:

Originally Posted by Publisher Bucks (Post 22961385)
Thanks.

That 'Status' one just seems to be on GFY, its not on the server version, must have just been a FF issue.

Would you possibly be able to share the php code that I can use to check MySQL for errors? :D

This: https://www.w3schools.com/php/func_mysqli_error.asp

sarettah 02-03-2022 02:45 PM

Quote:

Originally Posted by Klen (Post 22961411)

That would work.

.

blackmonsters 02-03-2022 02:54 PM

Quote:

Originally Posted by sarettah (Post 22961367)
Without knowing more about the table you are inserting into, it is hard to say. Could be duplicate entry on a unique index, not sure. Also not sure what level you are reporting errors. When I am in development mode I have all error reporting php and mysql turned on so I can see anything that goes wrong. I also put message s in the code so I can see exactly what is happening and when.

However, in what you posted, if it is the code that you are running there is a space in '$status' that should not be there, but that should blow it off every time not just on subsequent runs.

Yeah, I dont see an "ID" field in the insert code.
The DB is set to "auto index"; but he has no field defined for the auto index.


// Insert user data into table
$result = mysqli_query($mysqli, "INSERT INTO DomainManagement(Registrar,DomainName,Registration ,Expiration,NameServer1,NameServer2,Status,Notes) VALUES('$Registrar','$DomainName','$Registration', '$Expiration','$NameServer1','$NameServer2','$Stat us','$Notes')");

The SQL table should have a record ID field. (You can do anything you want but ID is standard)
The ID will be "" in the data fields so that SQL will create the ID number on insert for you.

The code should look like this, I think.

// Insert user data into table
$result = mysqli_query($mysqli, "INSERT INTO DomainManagement(ID,Registrar,DomainName,Registration ,Expiration,NameServer1,NameServer2,Status,Notes) VALUES("", '$Registrar','$DomainName','$Registration', '$Expiration','$NameServer1','$NameServer2','$Stat us','$Notes')");


:2 cents:

Publisher Bucks 02-03-2022 06:39 PM

Thank you all for the help, I fixed the issue.

It was a messed up AI/NULL setting in the table.

mikeworks 02-07-2022 06:35 AM

I recommend Mamp Pro/xDebug/Phpstorm. Using xDebug you can see what is happening at each step to help debug things.

Klen 02-07-2022 06:37 AM

Quote:

Originally Posted by mikeworks (Post 22962546)
I recommend Mamp Pro/xDebug/Phpstorm. Using xDebug you can see what is happening at each step to help debug things.

I know for Xdebug, but it's nothing special - i for debugging using command php -l, and so far there was no need for anything else. There is also option to use IDE like netbeans which have integrated debugger.


All times are GMT -7. The time now is 09:43 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123