Welcome to WebmasterWorld Guest from 54.196.244.186

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Can you spot the error please

help appreciated

     

UK_matrix

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

Inactive Member
Account Expired

 
 


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.

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

Administrator

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

joined:July 24, 2001
posts:15755
votes: 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)

Preferred Member

10+ Year Member

joined:May 3, 2001
posts:365
votes: 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")

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

Administrator

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

joined:July 24, 2001
posts:15755
votes: 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)

Preferred Member

10+ Year Member

joined:May 3, 2001
posts:365
votes: 0


True.
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)

Preferred Member

10+ Year Member

joined:Nov 30, 2001
posts:373
votes: 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)

Administrator

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

joined:July 24, 2001
posts:15755
votes: 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

11:02 pm on Mar 6, 2002 (gmt 0)

Inactive Member
Account Expired

 
 


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

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members