Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About Steve_Berry

  • Rank
  1. After several attempts, I now have data displayed on my index.php page, but the data is from all rows. Luckily I have two rows. The page also has a menu - with two links. What I would like help with is: How to display index.php with just the data for it - i.e. home page data. How to display data if either the ‘home’ or ‘copyright’ links are clicked. I understand you can use $_GET[‘id’], and isset(), but I don’t know how to do that. I include the full html page code: <?php // database connection require_once('admin/databasecon.php'); ?> <!DOCTYPE html>
  2. Thanks everyone. Will look into PDO further for more help.
  3. I assume you mean the following: try { $conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password); // set the PDO error mode to exception $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //echo "Connected successfully"; } catch(PDOException $e) { echo "Connection failed: " . $e->getMessage(); } As a point of interest I changed - echo "<pre>" . print_r($result, 1) . "</pre>"; To - echo "<pre>" . print_r($conn, 1) . "</pre>"; To which I got the following: This is - or would be the menu f
  4. <td class="navItem"> <?php echo "<pre>" . print_r($result, 1) . "</pre>"; if(!empty($result)) { foreach($result as $row) { ?> <a href="index.php?id=<?php echo $row['id']; ?>"><?php echo $row['menuheader']; ?>echo</a> <?php } } ?> </td> This now gives me an error: Notice: Undefined variable: result in C:\xampp\htdocs\testsite\index.php on line 33. I assume this means is not set. How do I remove this error?
  5. Hi, Assuming I placed the code you provided in the correct place, I still do not see anything either in the source code - blank space where the link should be, or on the page itself. Just to make sure, is the following correct? <td class="navItem"> <?php if(!empty($result)) { foreach($result as $row) { echo "<pre>" . print_r($result, 1) . "</pre>"; die(); ?> <a href="index.php?id=<?php echo $row['id']; ?>"><?php echo $row['menuheader']; ?>echo</a>
  6. Hello, yes and the link is missing: I don't see anything in the CSS that would cause this to happen. As a test I added HTML code to see the link. No idea why I don't see the php version [<a href="index.php?id=<?php echo $row['id']; ?>"><?php echo $row['menuheader']; ?></a>].
  7. Hello. I am attempting to display content from a database to a web page. I have SELECT * etc to do this, plus the menu that should be displayed has links to pages. This would display text to the page depending on the link, for this to work I use the id of the page ($Get['id']). Following advice (not code), I have attempted the following: <!DOCTYPE html> <html> <?php include 'includes/headsection.php'; ?> <body> <?php // query database if (!empty($_GET['id']) && (intval($_GET['id']) == $_GET['id'])) { $pdo_statemen
  8. Thanks all. Will take your advice and make changes.
  9. Hello. I am using a form to send data to my database but when I submit the form, the data is not shown on the database. I am connected to the database so I don't think the problem lies there. Also, I have a redirect option via 'Location:' which also works. I am following online examples for the php. This is the PHP I am using: <?php include("dbcon/database-conn.php"); if (!empty($_POST)) #($_SERVER["REQUEST_METHOD"] == "POST") { $pagelinks = $_POST['pagelinks']; $title = $_POST['title']; $asideleft = $_POST['asideleft']; $body = $_POST['body']; $asideright = $_PO
  10. Thanks for the help. The advice helped. I am following a tutorial that has caused issues. However, as I am new to PHP and/or PDO I am sticking with the PHP tutorial. That wy, some day I can figure out how to use PHP without tutorials. Once, again, thanks.
  11. What I am trying to do is to associate a user (id) to a page they create, so if joe blogs is user 4, then the data base will show the page details, and add the id (from a user page). However, when I try the code to save data I get the following error messages: Notice: Undefined offset: 4 in C:\xampp\htdocs\MyCMS\admin\index.php on line 98 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' 'Thom\'s page', 'testing Tom', 'Tom')' at line 1 I include the code to insert the page: <!-- Insert
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.