php


SQL Update Command updates all values in a column


So in my website I'm trying to make a page where people can edit which URL is in a certain mySQL table, here is my code before I go any further (for at least one part of it)
while($row=mysql_fetch_array($result))
{
$title = $row['title'];
$url=$row['url'];
$id = $row['inid'];
echo "<input type='button' id='delete' value='X' onclick='return Deleteqry($id)' />";
echo "<form action='admin.php' method='POST'><input type='text' name='urledit' /><input type='submit' name='redit' /></form>";
echo $title . '</br>';
echo $url . '</br></br>';
if(isset($_POST['redit']))
{
$newd = $_POST['urledit'];
mysql_query("UPDATE `insects` SET url = '$newd' WHERE inid = $id ");
header("location: admin.php");
}
}
Except the only problem is taht after they submit their value, it updates all the "url" rows in the table. Can anyone help me here?
If the row type for inid is int, remove the single quotes from the tablename, as well as from the 2 at the end, as it is an integer.
mysql_query("UPDATE insects SET url = '$newd' WHERE inid = 2 ");
Try changing the single quotes around your table name to backticks and remove the single quotes from 2 since it is an integer.
Also check your database to make sure you have not inadvertently changed all values in that column to 2 when testing an earlier query.
mysql_query("UPDATE 'insects' SET url = '$newd' WHERE inid = '2' ");
You are always updating the rows where inid=2, so i'm guessing all you urls in your db have inid with value '2'
Brother,
Did you chack your table? are you using auto increment for inid.
please check your table is inid has same values.
I didnt see any mistakes on your query.

Related Links

Postman: How to execute Paypal CURL Request in Postman?
Wordpress/Woocommerce only show category to a single role
grouping in codeigniter sql
How To Use cURL without http://www Prefix
cakephp 3 and logout confusion
How to check if *any* GET field is populated html php
Facebook sharer, thumb is showed instead of large image
Laravel Validator: insensitive regex rule?
PHP CodeIgniter - How to count images inside folders and their respective subfolders
how to combine 2 model requests into one query
What does statelessness mean in a RESTfull service
Elasticsearch: How do I index thousands of files using mapping?
How to add sender name another language in php mail
PHPmyadmin still giving Error Afert Re installing LAMPP severals times
php pagination array memory usage and process
Mysql Full text search in PHP returning multiple values

Categories

HOME
openshift
clearcase
eclipse-plugin
adfs3.0
selenium-builder
adobe
out-of-memory
slider
semantic-web
header
google-sheets-query
tfs2015
implicit-conversion
firebase-database
cocotb
spring-security-oauth2
locationmanager
csrf
mahout-recommender
orange-api
android-5.1.1-lollipop
home
ratio
python-imageio
macromedia
spring-annotations
ibm-connections
xenapp
snap-framework
bean-validation
cups
pdfnet
bluemixtools
ng-repeat
mars-simulator
flowchart
oauth2-playground
pyttsx
minikube
linq-to-excel
karabiner
watir-webdriver
hmmlearn
metabase
ndk-build
bilinear-interpolation
always-on-top
dojo-build
wicked-pdf
jemdoc
accessibilityservice
teamviewer
wikimedia-commons
smart-tv
stack-smash
variable-length-array
google-maps-api-2
mousehover
bjam
espresso
artisan
flow-js
quercus
configurable-product
mfmessagecomposeview
miglayout
nodeload
wso2bam
map
jmenubar
discovery
mousemotionlistener
insertion
semicolon
tfs-sdk
itunes-sdk
handshake
system-requirements
struts2-json-plugin
chronometer
viewpagerindicator
gamesalad
platform-independent
firebird1.5
n-queens
play2-mini
representation
startupscript
upshot
nsconnection
gaelyk
ccnet-config
aggregator
odac
eventaggregator
rational-unified-process
mysqli-multi-query
accumulator
gui-designer

Resources

Encrypt Message