Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

insert into

Featured Replies

Hi guys this script isnt working my form is here.

 

<form method="POST" action="index2.php">
<input type="text"  name="title"/>
<input type="text"  name="comment"/>
<input type="submit" name="submit" value="Post Comment" />
</form>

 

 

php is here

<?php
session_start();


//connection is present here
$sql_statement = "INSERT INTO blog_pettit (title, comment) VALUES ('title', 'comment')";
$results = mysqli_query($mysqli, $sql_statement);

if ($results == TRUE) {
	echo "Your comment has been posted.";
} else {
	printf("Could not create post: %s\n", mysqli_error($mysqli));
}
mysqli_close($mysqli);
}
?>

 

no errors nothing?

 

 

Cheers

  • Author

Have you actually connected to the database? Do you have error reporting turned on?

 

obviously thats why it says

 

//connection is present here, i am not going to put the actual connection in.

 

error reporting is on

nothing is being displayed.

 

cheers

Hi guys this script isnt working my form is here.

 

<form method="POST" action="index2.php">
<input type="text"  name="title"/>
<input type="text"  name="comment"/>
<input type="submit" name="submit" value="Post Comment" />
</form>

 

 

php is here

<?php
session_start();


//connection is present here
$sql_statement = "INSERT INTO blog_pettit (title, comment) VALUES ('title', 'comment')";
$results = mysqli_query($mysqli, $sql_statement);

if ($results == TRUE) {
	echo "Your comment has been posted.";
} else {
	printf("Could not create post: %s\n", mysqli_error($mysqli));
}
mysqli_close($mysqli);
}
?>

 

no errors nothing?

 

 

Cheers

 

try

 

$sql_statement = "INSERT INTO blog_pettit (`title`, `comment`) VALUES ('title', 'comment')";

nope. lol

 

Ok rewrite the whole thing like this

 

<?php
session_start();


       //connection is present here
       $sql_statement = "INSERT INTO blog_pettit (`title`, `comment`) VALUES ('title', 'comment')";
       $results = mysqli_query($mysqli, $sql_statement);

       if (mysqli_errno($results)) {
            die(mysqli_error($mysqli));
       } else {
         echo "Your comment has been posted";
       }
       mysqli_close($mysqli);
}
?>

 

and to clarify make sure error_reporting is at the top of the page above session start and that it looks like ERROR_REPORTING(E_ALL);

  • Author

still nothing.... no errors just a blank page. no data is being inserted into the database either!?

 

Craig

Have you actually had PHP errors show before? You need to set them to display as wel

ini_set('display_errors', 1);

 

If it's not showing anything then clearly there is a parse error. Have you checked your error log files?

  • Author

Mmmmm thats very odd as i can see nothings wrong with ur query

 

i know i always have these problems. my host wont take any responibity for it either...

i know i always have these problems. my host wont take any responibity for it either...

mmm after all ur code do echo "Hello world"; see if that outputs if it does not u odviously have a hidden parse error

 

EDIT: ok i just noticed something whats the last }

bracket right before the closing php tag suppose to be going to? it looks like u need to remove that

Edited by webdesigner93

  • Author

Ok i am literally a massive idiot.

i wouldnt usually own up to this but u all deserve a laugh!!!

 

I didnt upload the file!!

HAA

yeah its not echoing anything out.

 

did u remove the bracket before the closing php tag? once thats removed should look like this

 

<?php
session_start();


       //connection is present here
       $sql_statement = "INSERT INTO blog_pettit (`title`, `comment`) VALUES ('title', 'comment')";
       $results = mysqli_query($mysqli, $sql_statement);

       if (mysqli_errno($results)) {
            die(mysqli_error($mysqli));
       } else {
         echo "Your comment has been posted";
       }
       mysqli_close($mysqli);

?>

Edited by webdesigner93

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.