• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Anyone good with sql/php?

Atvar

Senior member
I am trying to set up a simple database driven website. For some reason, whenever I try and take info from a form and send it to a database, all I get is a blank line. I can insert fine from the command line as well as hardcoding the info into a php script. When I use a form, the data never gets passed. For the life of me I can't see why. I have simplified the code so much and still nothing. Here is the form:

<HTML>

<BODY>

<form action="entry.php" method="post">
link:<input name="bookmark" type=text>

<input type=submit value="Add Link">
</form>

</BODY>
</HTML>


And the php script:

<?


$connection = mysql_connect("localhost", name, pass) or die ("could not connect to mysql!");

mysql_select_db("links", $connection)or die("could not select database");


$query = "INSERT into data(hyperlink) VALUES ('$bookmark')";

mysql_query($query);

mysql_close($connection);


?>

I have tried just printing out the $bookmark variable. Blank. I really can't figure out what is going on here. If someone can point out my stupid mistake so I can move on, I will be eternally grateful. Thanks

Atvar
 
Originally posted by: jonmullen
And the answer was Global variables turned off.

And there is a reason why it's turned off and SHOULD be turned off.

I didn't want to tell him he can solve the problem by just turning global variables on because that would be not too sound of an advice to give.
 
I must be a n00b. Why should they be kept off? Security, I assume...but, how would it directly affect it?
 
Originally posted by: onelin0
I must be a n00b. Why should they be kept off? Security, I assume...but, how would it directly affect it?

Because it could be exploited by people to make the script do what the author did not intended. With global turned on, anyone can assign anything to a variable in your script.
 
Back
Top