SQLITE php script writing two variables on different rows?

  • Thread starter Thread starter Bob Hoil
  • Start date Start date
B

Bob Hoil

Guest
I am using an sqlite database and php script to write information to it! I have a table called servs and inside that two categories name, and ip. For some reason whenever I write to the database it will write the name then go to the next row and write the ip address. It should not do this I do not think! I need it so it writes them both to the same line.

<?php
$db = sqlite_open("******");
$servername = $_GET['servername'];
$ip = $_GET['ip'];

if (isset($servername) && isset($ip)) {
sqlite_query($db, "INSERT INTO servs (name) VALUES ('$servername')");
sqlite_query($db, "INSERT INTO servs (ip) VALUES ('$ip')");
}

// execute query
$result = sqlite_query($db, 'SELECT * FROM servs');
if (($result) > 0) {
while ($entry = sqlite_fetch_array($result, SQLITE_ASSOC)) {
echo 'Name: ' . $entry['name'] . ' IP: ' . $entry['ip'];
}
}
// close database connection
sqlite_close($db);
?>
 
Back
Top