Page 1 of 1
inserting "name" inseat of the value for $name
Posted: Mon May 31, 2004 3:47 pm
by Ne0
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>";
?>
Posted: Mon May 31, 2004 3:52 pm
by feyd
maybe the case is wrong or something.. try print_r($_POST); see what that kicks out..
Posted: Mon May 31, 2004 4:04 pm
by Ne0
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...
Posted: Mon May 31, 2004 4:11 pm
by feyd
well.. at least the variable is working right.. now just to figure out why $_POST['name'] contains name, instead of what you are expecting..

Posted: Mon May 31, 2004 4:25 pm
by Ne0
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'>
Posted: Mon May 31, 2004 4:46 pm
by feyd
yeah, try changing it..
Posted: Mon May 31, 2004 4:47 pm
by Ne0
yea, but to what? i mean i havent seen one thing wrong yet, nothing wrong at all, and nothing that would do this
Posted: Mon May 31, 2004 4:48 pm
by feyd
name='name' to name='n'.. then $_POST['n'].. seems odd, but that may be the problem..
Posted: Mon May 31, 2004 4:50 pm
by Ne0
hmm, it worked.
i wonder why it would do that.
o well, thanks for your time and help

Posted: Mon May 31, 2004 5:02 pm
by feyd
the browser may be getting confused..
Posted: Mon May 31, 2004 10:03 pm
by JAM
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"
Posted: Mon May 31, 2004 10:44 pm
by feyd
very true, Jam.
Posted: Tue Jun 01, 2004 2:05 pm
by Ne0
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
Posted: Wed Jun 02, 2004 2:18 am
by JAM
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).