Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
Ne0
Forum Commoner
Posts: 60 Joined: Sat Feb 14, 2004 11:48 am
Post
by Ne0 » Mon May 31, 2004 3:47 pm
ok, this works absolutly fine, except instead of inserting the value for $name, it physically inserts the word "name". the wierd thing is it didnt do anything like this for the other values, just $name.
o yea, i guess the code would help:
Code: Select all
<?php
page = $_POST['page'];
$name = $_POST['name'];
$url = $_POST['url'];
$author = $_POST['author'];
$authorurl = $_POST['authorurl'];
$content = $_POST['content'];
$sql = mysql_query("INSERT INTO tbl_content (id,page,name,url,clicks,description,author,authorurl) VALUES('','$page','$name','$url','','$content','$author','$authorurl')") or die ("Error ".mysql_errno().": ".mysql_error()."\nQuery: $sql");
echo "Your content has been added succesfully.<br><center><a href='admini.php'></center></a>";
?>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon May 31, 2004 3:52 pm
maybe the case is wrong or something.. try print_r($_POST); see what that kicks out..
Ne0
Forum Commoner
Posts: 60 Joined: Sat Feb 14, 2004 11:48 am
Post
by Ne0 » Mon May 31, 2004 4:04 pm
ok, i got back:
Array ( [page] => examples [name] => name [url] => asd [author] => asd [authorurl] => asd [content] => asd )
that doesnt look good...it sais name is name...
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon May 31, 2004 4:11 pm
well.. at least the variable is working right.. now just to figure out why $_POST['name'] contains name, instead of what you are expecting..
Ne0
Forum Commoner
Posts: 60 Joined: Sat Feb 14, 2004 11:48 am
Post
by Ne0 » Mon May 31, 2004 4:25 pm
yea, i rele dont understand it, could it have to do with the form?
Code: Select all
<form action='admini.php?a=addcontent' method='post'>Add Content:<br>Page:<input type='text' class='text1' name='page'><br>
Name:<input type='text' class='text1' name='name'><br>
URL:<input type='text' class='text1' name='url'><br>
Author:<input type='text' class='text1' name='author'><br>
Auth. URL:<input type='text' class='text1' name='authorurl'><br>
Description:<textarea name='content' cols='40' rows='4' class='text1'></textarea><br>
<input type='submit' class='text1' value='Add'>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon May 31, 2004 4:46 pm
yeah, try changing it..
Ne0
Forum Commoner
Posts: 60 Joined: Sat Feb 14, 2004 11:48 am
Post
by Ne0 » Mon May 31, 2004 4:47 pm
yea, but to what? i mean i havent seen one thing wrong yet, nothing wrong at all, and nothing that would do this
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon May 31, 2004 4:48 pm
name='name' to name='n'.. then $_POST['n'].. seems odd, but that may be the problem..
Ne0
Forum Commoner
Posts: 60 Joined: Sat Feb 14, 2004 11:48 am
Post
by Ne0 » Mon May 31, 2004 4:50 pm
hmm, it worked.
i wonder why it would do that.
o well, thanks for your time and help
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon May 31, 2004 5:02 pm
the browser may be getting confused..
JAM
DevNet Resident
Posts: 2101 Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:
Post
by JAM » Mon May 31, 2004 10:03 pm
feyd wrote: the browser may be getting confused..
We should also mention that the more correct way of quoting values is by using double (") quotes. Ie:
Code: Select all
Bad:
name='name'
Better:
name="name"
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon May 31, 2004 10:44 pm
very true, Jam.
Ne0
Forum Commoner
Posts: 60 Joined: Sat Feb 14, 2004 11:48 am
Post
by Ne0 » Tue Jun 01, 2004 2:05 pm
do you mean in thr form? well, i put it in a echo function, so i used single. i guess i could fix that.
thanks again
JAM
DevNet Resident
Posts: 2101 Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:
Post
by JAM » Wed Jun 02, 2004 2:18 am
I personally meant the form (any html for that matter). It doesn't matter if you echo it out or use html itself, aways quote.
Code: Select all
echo '<input type="text" name="foo" value="'. $variable .'" />';
echo "<input type="text" name="foo" value="{$variable}" />";
echo <<<HEREDOC
<input type="text" name="foo" value="$variable" />
HEREDOC;
Should all create the same result (minus the spelling errors, im on a coffeebreak).