homepage Welcome to WebmasterWorld Guest from 54.166.84.82
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Can you spot the error please
help appreciated
UK_matrix

10+ Year Member



 
Msg#: 369 posted 7:40 pm on Mar 6, 2002 (gmt 0)

Hi,
I'm back. I've added a field to a table and I want to populate it with the values in another table. I have written this basic code so I can call it at my browser. This is so I can do it one record at a time, ie.

www.mydomain.com/update.php3?id=1

I have all required permissions and both tables match id for id. But this script does not update even though it seems to follow the syntax in the manual. The request to the table membersid is successful and brings in the value I need.

(any value xxxxx is for security reasons :)

<?php

// connect to database
$db = mysql_connect("localhost", "xxxxx", "xxxxx");
mysql_select_db("xxxxxxxxx");

// get value from existing column
$result = mysql_query("SELECT * FROM membersid WHERE id=$id");
$myrow = mysql_fetch_array($result);
$actualid=$myrow["actualid"];

// update new column
$result1 = mysql_query("UPDATE members SET actualid=$actualid WHERE id=$id");

?>

As always, thanks in advance for any help.

 

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 369 posted 7:48 pm on Mar 6, 2002 (gmt 0)

have you tried these queries while in mysql, through telnet?

do you get an error or does it not do anything at all?

circuitjump

10+ Year Member



 
Msg#: 369 posted 7:51 pm on Mar 6, 2002 (gmt 0)

Write it like this

$result = mysql_query("UPDATE members SET actualid='".$actualid."' WHERE id=".$id)

or

$result = mysql_query("UPDATE members SET actualid='$actualid' WHERE id=$id")

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 369 posted 7:54 pm on Mar 6, 2002 (gmt 0)

if the fields are ints though that won't matter becasue they don't require single quotes.

circuitjump

10+ Year Member



 
Msg#: 369 posted 7:57 pm on Mar 6, 2002 (gmt 0)

True.
Check the database through telnet like jatar_k said.

I always forget about ints not needing it.

amoore

10+ Year Member



 
Msg#: 369 posted 7:59 pm on Mar 6, 2002 (gmt 0)


do you check the values of $result or $result1 anywhere? what is in your error logs?

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 369 posted 8:06 pm on Mar 6, 2002 (gmt 0)

I was wondering,

>>UPDATE members SET actualid=$actualid WHERE id=$id

if you are trying to set actualid == id shouldn't you be comparing a different field in your where statement?

I could be misunderstanding what you are trying to do

UK_matrix

10+ Year Member



 
Msg#: 369 posted 11:02 pm on Mar 6, 2002 (gmt 0)

Thanks for all the responses.

The first example by circuitjump did the trick.

This is a great forum. Quick and accurate responses, look out for me again as I get deeper into PHP :)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved