Jump to content

Recommended Posts

Here is my code:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Examples
</title>
</head>

<?php

if(!isset($_POST['text'])) {
echo "<form action='/examples/index.php' method='post'>";
echo "<input type='text' name='text'>";
echo "<input type='submit'>";
echo "</form>";
} else {
$text = mysql_escape_string($_POST['text']);
$mysql_connect = mysql_connect('localhost', 'brian', '');

mysql_query("UPDATE `08-12345-1` SET Req=($text) WHERE PermitProcess='COUNTY PRE-APP MEETING'", $mysql_connect);

mysql_close($mysql_connect);

echo "The record was updated in your MySQL database!";
}

?>

<body>
</body>
</html>

 

I execute

 

UPDATE `08-12345-1` SET Req='some_text' WHERE PermitProcess='COUNTY PRE-APP MEETING'

 

in the phpMyAdmin query window and it works just fine, updates the table in my browser, but when I go to use the same statement in this script, it doesn't want to cooperate... :| anyone see any problem with it? I'll be really excited if somebody can figure this out, as I've been at this same part of my website for about a week now, with no further progress due to this problem.

Link to comment
https://forums.phpfreaks.com/topic/103900-why-wont-my-table-update/
Share on other sites

AHHHH!!!! Still doesn't work. I'm about to pull my hair out :o Arg.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Examples
</title>
</head>

<?php

if(!isset($_POST['text'])) {
echo "<form action='/examples/index.php' method='post'>";
echo "<input type='text' name='text'>";
echo "<input type='submit'>";
echo "</form>";
} else {
$text = mysql_escape_string($_POST['text']);
$mysql_connect = mysql_connect('localhost', 'brian', '');

mysql_query("UPDATE `08-12345-1` SET Req='$text' WHERE PermitProcess='COUNTY PRE-APP MEETING'");

mysql_close($mysql_connect);

echo "The record was updated in your MySQL database!";
}

?>

<body>
</body>
</html>

 

This is what I have now, after changing what you stated. I just don't understand why it works in the query window in phpMyAdmin but not when put into this script... >.>

replace these lines:

$mysql_connect = mysql_connect('localhost', 'brian', '')
  or die("Failed to connect");
$text = mysql_escape_string($_POST['text']);
mysql_query("UPDATE `08-12345-1` SET Req='$text' WHERE PermitProcess='COUNTY PRE-APP MEETING'")
  or die("Update error: ".mysql_error());
mysql_close($mysql_connect);

$text won't be set to anything because you are using mysql_escape_string() before you have a connection to a mysql server.

 

When learning php, developing php code, or debugging php code, do yourself a favor and turn off full php error_reporting and the display_errors setting to get php to help you.

Now it's telling me no database selected >.> I clearly see I have one selected `08-12345-1` .. what's wrong with it now? :[

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Examples
</title>
</head>

<?php

if(!isset($_POST['text'])) {
echo "<form action='/examples/index.php' method='post'>";
echo "<input type='text' name='text'>";
echo "<input type='submit'>";
echo "</form>";
} else {
$mysql_connect = mysql_connect('localhost', 'brian', '')
  or die("Failed to connect");
$text = mysql_escape_string($_POST['text']);
mysql_query("UPDATE `08-12345-1` SET Req='$text' WHERE PermitProcess='COUNTY PRE-APP MEETING'")
  or die("Update error: ".mysql_error());
mysql_close($mysql_connect);

echo "The record was updated in your MySQL database!";
}

?>

<body>
</body>
</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.