Im new to this but...

Im new to this but...

am 02.09.2008 21:05:31 von Chris Hale

I have:
Apache 2.0.59
MySQL 5.0.41
PHP 4.4.7 & 5.2.5

and this is my program:

session_start();
include("includes/functions_main.php");
include("Vars.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);
?>










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

Re: Im new to this but...

am 02.09.2008 21:13:14 von Joseph Crawford

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:
>
> > session_start();
> include("includes/functions_main.php");
> include("Vars.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);
> ?>
>


>

>


>
>

>

>
>
>
> 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

Re: Im new to this but...

am 02.09.2008 21:32:16 von Micah Gersten

In the HTML, you either need to use or, if you
have short tags on, , not .

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



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:
>
> > session_start();
> include("includes/functions_main.php");
> include("Vars.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);
> ?>
>


>

>


>
>

>

>
>
>
> 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