PDA

View Full Version : PHP Script



HabbDance
10-11-2008, 12:10 AM
I'm working on my first PHP script. It's a panel for my rare values. I'm only trying to get the forum to work atm, then I am going to integrate it into the values. Remember this is my first, and it's probably 100% wrong, so don't yell at me (dentafrice -cough-) lol jk :D

Here it is:

rare_edit.html


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd (http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)">
<html xmlns="http://www.w3.org/1999/xhtml (http://www.w3.org/1999/xhtml)">
<head>
<meta http-equiv="content-type" content="text/xml; charset=utf-8" />
<title>HabbDance Rare Value Database</title>
</head>
<body>
<h2>Rare Value Editor v1</h2>
<form action="rare_edit.php" method="post">
<fieldset><br />
<p>
<label>Which rare would you like to edit today?</label>
<select name="rare">
<option value = "Typewriter">
Typewriter
</option>
<option value = "Throne">
Throne
</option>
<option value = "HC_Sofa">
HC Sofa
</option>
</select><br />
What is this rare worth? <input type="text" name="value" /><br />
<label>What is the status of this rare?</label>
<select name="status">
<option value = "Increasing">
Increasing
</option>
<option value = "Stable">
Stable
</option>
<option value = "Decreasing">
Decreasing
</option>
</select>
</p>
<button type = "submit">
Change
</button>
</feildset>
</form>
</body>
</html>


rare_edit.php


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd (http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)">
<html xmlns="http://www.w3.org/1999/xhtml (http://www.w3.org/1999/xhtml)">
<head>
<meta http-equiv="content-type" content="text/xml; charset=utf-8" />
<style type="text/css">
<!--
body {
font-family: Verdana;
font-size: 12px;
-->
</style>
<title>HabbDance Rare Value Database</title>
</head>
<body>
<h2>Rare Value Editor v1</h2>
<? php
//gather the variables
$rare = $_REQUEST["rare"];
$value = $_REQUEST["value"];
$status = $_REQUEST["status"];

print "You have succesfully update $rare to $value, $status."
?>
</body>
</html>


I keep getting this when I submit the forum:
Parse error: syntax error, unexpected T_VARIABLE in /homepages/34/d237406810/htdocs/wsb4850525601/beta/db/rare_edit.php on line 19

So help please :] Thanks!

wazup999
10-11-2008, 12:17 AM
first it's <?php and nt <? php

2nd $rare = $_REQUEST['rare']; and not ""

It think lol,
waz ;]

HabbDance
10-11-2008, 12:27 AM
Thanks so much :D Worked great! +rep

&***** at your sig :D

Iszak
10-11-2008, 12:38 AM
Default
first it's <?php and nt <? php

2nd $rare = $_REQUEST['rare']; and not ""

It think lol,
waz ;]
No you can use both " and ' in $_REQUEST also for HabbDance I would reconsider using $_REQUEST as not only someone could easily submit the form via a $_GET request but it could also cause conflicts if you have a $_COOKIE or $_GET or $_POST that are the same key unless request order is specified. So avoid the hassle and use $_POST. Also Wazup is right, since <? signifies a short-tag opening, it sees it as <? followed by php which isn't in context of opening.

Hypertext
10-11-2008, 12:42 AM
No you can use both " and ' in $_REQUEST also for HabbDance I would reconsider using $_REQUEST as not only someone could easily submit the form via a $_GET request but it could also cause conflicts if you have a $_COOKIE or $_GET or $_POST that are the same key unless request order is specified. So avoid the hassle and use $_POST. Also Wazup is right, since <? signifies a short-tag opening, it sees it as <? followed by php which isn't in context of opening.

I'm sure a total PHP beginner could easily understand that. :rolleyes:

@OP: There isn't anything wrong with using $_REQUEST, but it can pose a security problem in some situations.

HabbDance
10-11-2008, 12:43 AM
No you can use both " and ' in $_REQUEST also for HabbDance I would reconsider using $_REQUEST as not only someone could easily submit the form via a $_GET request but it could also cause conflicts if you have a $_COOKIE or $_GET or $_POST that are the same key unless request order is specified. So avoid the hassle and use $_POST. Also Wazup is right, since <? signifies a short-tag opening, it sees it as <? followed by php which isn't in context of opening.
thanks, I'll use $_POST from now on.


I'm sure a total PHP beginner could easily understand that. :rolleyes:

@OP: There isn't anything wrong with using $_REQUEST, but it can pose a security problem in some situations.
Your right, didn't understand a word, but I consider Iszak a genius and take his advice :D

And I've run into another problem :S
The way I planned my database will only work for 1 value :p
How can I change it so that it will work for several?

Hypertext
10-11-2008, 12:47 AM
thanks, I'll use $_POST from now on.
And I've run into another problem :S
The way I planned my database will only work for 1 value :p
How can I change it so that it will work for several?

Have a table like:

ID rareName rareValue
1 Throne 28hc
2 HC 1hc/70rd

Jackboy
10-11-2008, 07:20 AM
Have a table like:

ID rareName rareValue
1 Throne 28hc
2 HC 1hc/70rd

I thought your were site coder??

@ontopic, Why are you doing php when you can't do html?

Decode
10-11-2008, 07:55 AM
the submit button should be
<input type="submit" value="Submit" />

Hypertext
10-11-2008, 01:51 PM
I thought your were site coder??

@ontopic, Why are you doing php when you can't do html?

I resigned, I'm way too busy.

Want to hide these adverts? Register an account for free!