SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 update where
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dustty
Starting Member

8 Posts

Posted - 08/16/2012 :  15:51:55  Show Profile  Reply with Quote
table pads with first field pname... val $name
I get a server error in this php. The error is in the update line & I have changed syntax and tried everything i know. What is wrong with this? I want to update the parameters for whatever row contains the $name..
<?php
$name = $_POST["pad"];
$gx = $_POST["xr"];
$gy = $_POST["yr"];
$gz = $_POST["zr"];
$mx = $_POST["xg"];
$mz = $_POST["yg"];

   
echo "xx$name";
    

$link = mysql_connect('localhost', 'whitebu4_admins', '****');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db('whitebu4_regions', $link);
if (!$db_selected) {
    die ('no db ' . mysql_error());
}
else {
UPDATE pads SET global_x ='$gx' WHERE pname = '$name';// , global_y='$gy' , Global_z='$gz' , google_x ='$mx' , google_y ='$mz' WHERE pname = '$name';
}

msqli_close($dbc);
?>

Edited by - dustty on 08/16/2012 16:04:49

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 08/16/2012 :  16:00:09  Show Profile  Reply with Quote
doesnt seem like t-sql. are you using sql server?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8513 Posts

Posted - 08/16/2012 :  16:08:25  Show Profile  Visit webfred's Homepage  Reply with Quote
you have to use mysql_query(), you cant write the update statement direct in your php code...

http://php.net/manual/de/function.mysql-query.php


Too old to Rock'n'Roll too young to die.
Go to Top of Page

dustty
Starting Member

8 Posts

Posted - 08/16/2012 :  16:13:17  Show Profile  Reply with Quote
I have this now with no errors but it doesnt update...

$sql = "UPDATE pads SET global_x ='$gx' WHERE pname = '$name'";
Go to Top of Page

dustty
Starting Member

8 Posts

Posted - 08/16/2012 :  16:16:05  Show Profile  Reply with Quote
Withthis I get server error msql_query(UPDATE pads SET global_x ='$gx' WHERE pname = '$name');
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8513 Posts

Posted - 08/16/2012 :  17:15:11  Show Profile  Visit webfred's Homepage  Reply with Quote
quote:
Originally posted by dustty

Withthis I get server error msql_query("UPDATE pads SET global_x ='".$gx."' WHERE pname = '".$name."'");


maybe this?


Too old to Rock'n'Roll too young to die.
Go to Top of Page

dustty
Starting Member

8 Posts

Posted - 08/16/2012 :  17:31:57  Show Profile  Reply with Quote
I have fought this for 4 or 5 days, read 40 dozen wikis and watched 40 dozen tuts. Tried inserts and about every php example given and now this update.

This code gives no errors but like all the rest nothing is changed in the data base. I have used mysql in the past What the hell have they done with the damn updates and versions?
<?php
$name = $_POST["pad"];
$gx = $_POST["xr"];
$gy = $_POST["yr"];
$gz = $_POST["zr"];
$mx = $_POST["xg"];
$mz = $_POST["yg"];

   
echo "xx$name";
    

$link = mysql_connect('localhost', 'whitebu4_admins', 'admins123');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db('whitebu4_regions', $link);
if (!$db_selected) {
    die ('no db ' . mysql_error());
}
else {

$result = msql_query("UPDATE pads SET global_x ='$gx'  WHERE pname = '$name'");
if (!$result) {
    die('Invalid query: ' . mysql_error());}
}

echo "updated";


msqli_close($dbc);
?>

Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8513 Posts

Posted - 08/16/2012 :  17:52:15  Show Profile  Visit webfred's Homepage  Reply with Quote
In my last answer there was an approach to concatenate the variables - did you try my solution?


Too old to Rock'n'Roll too young to die.
Go to Top of Page

dustty
Starting Member

8 Posts

Posted - 08/16/2012 :  19:02:23  Show Profile  Reply with Quote
I just see my copied quote And maybe this? I dont see your approach.. Could you repost..
Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8513 Posts

Posted - 08/16/2012 :  19:14:12  Show Profile  Visit webfred's Homepage  Reply with Quote
msql_query("UPDATE pads SET global_x ='".$gx."' WHERE pname = '".$name."'");



Too old to Rock'n'Roll too young to die.
Go to Top of Page

dustty
Starting Member

8 Posts

Posted - 08/16/2012 :  19:37:27  Show Profile  Reply with Quote
Ok tried it I had an insert statement that worked...using those values.. I replaced it with your update statement. ,, It does not change the database. Can you tell why by comparing?

mysql_query("INSERT INTO pads (pname,global_x,global_y,global_z,google_x,google_y) VALUES('$name' , '$gx' , '$gy' ,'$gz', '$mx', '$mz')") or die(mysql_error());
Go to Top of Page

dustty
Starting Member

8 Posts

Posted - 08/16/2012 :  20:00:27  Show Profile  Reply with Quote
db http://s1141.photobucket.com/albums/n594/karyoker/?action=view¤t=db2.png" target="_blank"> http://s1141.photobucket.com/albums/n594/karyoker/?action=view¤t=db2.png
Go to Top of Page

dustty
Starting Member

8 Posts

Posted - 08/16/2012 :  20:01:11  Show Profile  Reply with Quote
db

Edited by - dustty on 08/16/2012 20:07:30
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000