Re: Im new to this but...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



You did everything perfectly in the email except for show what the error message was.

i am assuming your issue is with the line

$page = '$_GET[page]';

that should just be

$page = $_GET['page'];

The way you are doing it (inside single quotes) does not evaluate the array as a variable, rather PHP thinks the entire thing is just a string.

when you you do the query

$sql = "SELECT * FROM page WHERE id=$page";

Your query is actually

"SELECT * FROM page WHERE id=$_GET[page]";

Now changing that one line may fix the issue at hand but I will also suggest that you read articles, blog entries, etc about SQL Injection and how to cleanse your data before throwing a user submitted value at your database.

Thanks,
Joseph Crawford

On Sep 2, 2008, at 3:05 PM, Chris Hale wrote:

I have:
Apache 2.0.59
MySQL 5.0.41
PHP 4.4.7 & 5.2.5

and this is my program:

<?php
session_start();
include("includes/functions_main.php");
include("Vars.php");
?>   <?php get_header(); ?>
<?php get_sidebar(); ?>
<?php
  $page = '$_GET[page]';
$cxn = mysqli_connect($host, $user,$passwd, $database) or die ("Can't Connect.");
  $sql = "SELECT * FROM page WHERE id=$page";
  $result = mysqli_query($cxn, $sql);
  $row = mysqli_fetch_assoc($result);
  extract ($row);
?>
<div id="column_right">
  <div class="content">
      <h2><?php $title ?></h2>
          <?php $content ?>
  </div>
</div>
<?php get_footer();?>


But i get an error every time. I have read PHP and MySQL for Dummies to get me started but none of the things in the book seem to work for me. It is very frustrated. I dont know whether it just my lameass host provider that hasn't set the mysql properly.

I would appreciate any help.

Thanks

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux