Jump to content

patmon

New Members
  • Posts

    7
  • Joined

  • Last visited

patmon's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Also as you know I was using - $theid= $_GET['id']; I changed it using ctype_digit as CyberRobot said to do. Let me know if you guys see an issue with it. It works but not sure if it solves the sanitizing issue. if(ctype_digit($_GET['id'])){ $theid = $_GET['id']; } else { $theid = 0; }
  2. Well I tried $sql="SELECT * FROM thetable WHERE id = $theid" and since I added $result = mysqli_query($con,$sql) or die(mysqli_error($con)); it showed me an error... It said "Unknown column 'id' in 'where clause'" I thought "Mr Stupid" here id was saying the id is an indicator saying it's the id and = $id was the id column name.. if that makes sense. Sorry guys not a PHP guy here. So that told me that the column was wrong so I change it to the column name and it worked. Thank you to the both of you. You guys helped a lot.
  3. CyberRobot, I had $result = mysqli_query($con,$sql) so removed that and added - $result = mysqli_query($con,$sql) or die(mysqli_error($con)); There were no errors.
  4. PoH, I used $id = (int)$_GET['id'] but didn't change anything... still getting id=1 and id=2 but id=2 is still displaying the same content as id=1. I tried sql="SELECT * FROM thetable WHERE id = 2" and this worked. What I mean by that is id=2 showed id=2 content. But of course id=1 displayed id=2 content but that was to be expected. So what does this tell us?
  5. CyberRobot, I am doing error checking in the connection code but I see a few things I can try from the url you provided. Thanks
  6. PoH , Yes page 2 is connecting to the db but when I change to SELECT * nothing displays. And when I change it back to the page 2 example above - SELECT id, title, details it displays id 1 data for both id 1 and id 2. An yes the data is different. Can you give me an example of sanitizing? I see many examples but no uniform good way to do it. I'll try your examples after work. Thanks
  7. I'm using PHP and MySQL to display images on the first page. When the image is clicked on I'm passing an ID to a new page. I want that ID to display the ID data that's associated with that ID. For example: ID 1 should display - Title - title1, Details - details1, image - image1 and ID 2 ID 1 should dislay - Title - title2, Details - details2, image - image2 But only displaying ID 1 data not matter if the URL is - website.com/thedetials.php?id=1 or website.com/thedetials.php?id=2 In other words, it displays the same data even though the id in the URL is different. Page 1 $sql="SELECT * FROM thetable"; $result = mysqli_query($con,$sql); echo " <ul>"; while($row = mysqli_fetch_array($result) { echo "<li'>"; echo "<a href='page2.php?id=$row[id]'><img src=$row[image]></a>"; echo "</li>"; } echo "</ul>"; ?> <?php // End while loop. mysqli_close($con); ?> Page 2 $id = $_GET['id']; $sql="SELECT id, title, details, image, FROM thetable"; $result = mysqli_query($con,$sql); $row = mysqli_fetch_array($result); ?> <?php echo $row['title'] ?> <?php echo $row['details'] ?> <img class='projectItem-pic' src="<?php echo $row['image']?>"> If I use below - No data displays, not sure why. $sql="SELECT * FROM thetable WHERE id = $id"; Can someone tell me what I'm doing wrong?
×
×
  • 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.