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.

help! php annoying error, dunno why?

Featured Replies

iv built a cms and my edit_blog page isnt liking when i hit my save button. im getting the following message

 

Notice: Undefined index: blogID in C:\xampp\htdocs\nurd\admin\edit_blog.php on line 27

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

 

<?php
session_start();
include "connection.php";
if(!isset($_POST['submit'])) {
$q = "SELECT * FROM cmsblog WHERE blogID = $_GET[blogID]";
$result = mysql_query($q);
$row = mysql_fetch_array($result);
}
?>
<h1>Edit Page</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
Page Name: <input type="text" name="inputTitle" value="<?php echo $row['blogTitle']; ?>" /><br />
<br />
Content:<br />
<textarea name="inputContents" cols="100" rows="25"><?php echo $row['blogContents']; ?></textarea>
<br />
<input type="hidden" name="id" value="<?php echo $_GET['blogID']; ?>" />
<input type="submit" name="submit" value="Save" />
</form>
<?php
if (isset($_POST['submit'])) {
$u = "UPDATE pages SET `blogTitle`='$_POST[inputTitle]', `blogContents`='$_POST[inputContents]' WHERE blogID = $_POST[blogID]";
mysql_query($u) or die (mysql_error());

echo "Successful! Blog has been updated";
header("Location: controlpanel.php");
}
?>

Edited by dpuk44

Pal you need to read into sql injection protection and before you put that code online :) Hackers will be able to run there own sql commands with out protection :o

Edited by motters

iv built a cms and my edit_blog page isnt liking when i hit my save button. im getting the following message

 

Notice: Undefined index: blogID in C:\xampp\htdocs\nurd\admin\edit_blog.php on line 27

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

 

<?php
session_start();
include "connection.php";
if(!isset($_POST['submit'])) {
$q = "SELECT * FROM cmsblog WHERE blogID = $_GET[blogID]";
$result = mysql_query($q);
$row = mysql_fetch_array($result);
}
?>
<h1>Edit Page</h1>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
Page Name: <input type="text" name="inputTitle" value="<?php echo $row['blogTitle']; ?>" /><br />
<br />
Content:<br />
<textarea name="inputContents" cols="100" rows="25"><?php echo $row['blogContents']; ?></textarea>
<br />
<input type="hidden" name="id" value="<?php echo $_GET['blogID']; ?>" />
<input type="submit" name="submit" value="Save" />
</form>
<?php
if (isset($_POST['submit'])) {
$u = "UPDATE pages SET `blogTitle`='$_POST[inputTitle]', `blogContents`='$_POST[inputContents]' WHERE blogID = $_POST[blogID]";
mysql_query($u) or die (mysql_error());

echo "Successful! Blog has been updated";
header("Location: controlpanel.php");
}
?>

 

If you have a simple question like this ex-specially saying how to fix it. thats probably an indication you need to study php more before trying to build something like a CMS your code is not secure at all like mentioned above.

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.