homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
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

 7:40 pm on Mar 6, 2002 (gmt 0)

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.


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 :)


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

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

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


As always, thanks in advance for any help.



 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?


 7:51 pm on Mar 6, 2002 (gmt 0)

Write it like this

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


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


 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.


 7:57 pm on Mar 6, 2002 (gmt 0)

Check the database through telnet like jatar_k said.

I always forget about ints not needing it.


 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?


 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


 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