User CP :: Log in to check your private messages :: Chat :: Register :: Log in

Board Index :: Album :: FAQ :: Calendar :: Members :: Groups :: Staff ::
Search
Post new topic   Reply to topic
graphic PHP,MySQL and Moving stuffss Help needed graphic
Author Message PO Info
Hoth
Guitarist



Gender: Gender:Male
Joined: 10 Oct 2002
PostPosted: Sun Jan 23, 2005 2:47 am    Post subject: PHP,MySQL and Moving stuffss Help needed

Okay after a lot of reading and googling and such on php and mysql i cant seem to figure out what I am doing wrong. Below are the two pages im using to try and add monsters to a table in my db.

first is the form to fill out.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Monster Creation Tool ver 1.0 </TITLE>

</HEAD>

<BODY>


<!--<SCRIPT language="JavaScript">
function submitform()
{

document.monstersubmit.submit();


}
</SCRIPT>-->


<form name="monstersubmit" method="GET" action="monstersubmit.php3">
Monster Name: <input type='text' name='MName'>
<br>
Max Hp: <input type='text' name='MHP'>
<br>
Thaco: <input type='text' name='Thaco'>
<br>
AC: <input type='text' name='AC'>
<br>
Attacks: <input type='text' name='Atacks'>
<br>
Damage: <input type='text' name='Damage'>
<br>
Spelluse: <select name='Spelluse'>
<option value="Y">Yes</option>
<option value="N" >No</option>
</select>
<br>
Magic Resistance: <input type='text' name='MagRes'>
<br>
Experience Worth: <input type='text' name='Exp'>
<br>
<input type="Submit" value="Submit">


</form>

</BODY>
</HTML>

Second is the php page that is attempting to send info to the mysql database.

<html>
<body>

<?php
$location = "localhost";
$username = "root";
$password = "";
$database = "game";

$conn = mysql_connect("$location","$username","$password");
if (!$conn) die ("Could not connect MySQL");
mysql_select_db($database,$conn) or die ("Could not open database");




'Get the variable from the querystring.

ID=Request.Querystring("ID")
Mname=Request.Querystring("Mname")
MHP=Request.Querystring("MHP")
Thaco=Request.Querystring("Thaco")
AC=Request.Querystring("AC")
Atacks=Request.Querystring("Atacks")
Damage=Request.Querystring("Damage")
Spelluse=Request.Querystring("Spelluse")
MageRes=Request.Querystring("MageRes")
Ex=Request.Querystring("Exp")

'This sends the values to database

SQL= "INSERT INTO monsters (ID,MName,MHP,Thaco,AC,Atacks,Damage,Spelluse,MagRes,Exp) VALUES ("

SQL=SQL & "'" & ID & "', "
SQL=SQL & "'" & Mname & "', "
SQL=SQL & "'" & MHP & "', "
SQL=SQL & "'" & Thaco & "', "
SQL=SQL & "'" & AC & "', "
SQL=SQL & "'" & Atacks & "', "
SQL=SQL & "'" & Damage & "', "
SQL=SQL & "'" & Spelluse & "', "
SQL=SQL & "'" & MageRes & "', "
SQL=SQL & "'" & Ex & ")";


?>

<p>
CheckDB for correct entry!
</p>
</body>
</html>

Thanks for any help given.

_________________

Guitar - http://www.myspace.com/hothguitar
Band - http://www.myspace.com/brokenred
Reply with quote
Wins 39 - Losses 40
Level 10
EXP: 1931
HP: 2150
Eligible for battle!
STR: 950
END: 600
ACC: 900
AGI: 950
Illantier (Sword)
(280 - 490)
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Shino
Fade into this fantasy, caught in the web of time


Age: 49
Gender: Gender:Male
Joined: 15 Sep 2002
PostPosted: Mon Jan 24, 2005 10:23 am    Post subject:

Shino: what's with the sQL=SQL & "" & ...
Hoth: yeah.. on umm some php tutorial page it said to build it like that to pass it to my db
Shino: ok
Hoth: the only time ive seen that though was in xml i though
Hoth: t
Shino: so you are using & to concat a string
Hoth: yeah
Shino: ok
Shino: don't use htat
Hoth: <--unsure if that is right
Hoth: okay
Shino: you can do this...
Shino: sql .= "" . ID . ", ";
Shino: the '.' is your concat operator
Shino: and you can do '.=' the same way you do += in JS or java
Shino: or C++ Wink
Hoth: i have no clue what a concat operator is
Shino: haha
Shino: it's a + for Strings
Hoth: Smile
Hoth: ohh like the &
Shino: right
Shino: but I have never seen the &
Shino: it's ugly
Shino: and don't forget your ;s
Shino: you're missing a lot on that string construction
Hoth: i know that ; ends the command
Hoth: so i was putting it all into one line by not puttin the ; until the end
Shino: don't do that
Hoth: was i wrond
Hoth: okay
Hoth: Smile
Shino: and the line...
Shino: 'This sends the values to the database
Hoth: really
Shino: ths't being interpretted b/c the single quote is not a comment block
Hoth: i thought that was the comment out thingy
Shino: //This sends the values to the database
Hoth: wow
Shino: that's just for a quick look
Hoth: <---lots to learn
Shino: Request.Querystring... not sure how that works... never used it


So try that and get back to me bro.

Another thing you can try... instead of going straight to submitting to that file, actually point your browser at the file. It will tell you if there are any syntax errors in your code.

_________________
So many games... so little time


Reply with quote
Wins 190 - Losses 169
Level 21
EXP: 11590
HP: 3150
Eligible for battle!
STR: 1050
END: 1050
ACC: 1200
AGI: 1200
Bianco & Nero (Sabers)
(500 - 600)
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Hoth
Guitarist



Gender: Gender:Male
Joined: 10 Oct 2002
PostPosted: Mon Jan 24, 2005 12:20 pm    Post subject:

How in the world do I point my browser to that file. I though that was what this line did.



And I will try when i get home tonight.. Thanx

_________________

Guitar - http://www.myspace.com/hothguitar
Band - http://www.myspace.com/brokenred
Reply with quote
Wins 39 - Losses 40
Level 10
EXP: 1931
HP: 2150
Eligible for battle!
STR: 950
END: 600
ACC: 900
AGI: 950
Illantier (Sword)
(280 - 490)
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Display posts from previous:   
graphic graphic
Post new topic   Reply to topic Board Index -> Geek Haven
Page 1 of 1
All times are GMT - 4 Hours
Email this topic to a friend

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum