Forum Moderators: coopster
function updatedb($pagename){
global$PHP_SELF;
$dbuser="xx";
$dbpass="xx";
$db="gdon_contents";
$link=mysql_connect("localhost",$dbuser,$dbpass);
mysql_select_db($db,$link);
$dbresult=mysql_query("SELECT * FROM page$pagename");
$finalrow=mysql_num_rows($dbresult);
$field=mysql_fetch_array($dbresult);
for($z="1";$z<=$finalrow;$z++){
$vid1="content$z";
$vid2="show$z";
$query="UPDATE page$pagename SET content='$GLOBALS[$vid1]',name='',show='$GLOBALS[$vid2]',id='$z' WHERE id=$z";
if(!mysql_query($query,$link)){$dberror=mysql_error();echo $dberror;return false;}else{return true;}
echo "$GLOBALS[$vid1]<br>\n";
echo "Show: $GLOBALS[$vid2]<br>\n";
echo "Z: $z<br><br>";
}
}
This is the error returned:
You have an error in your SQL syntax near 'show='1',id='1' WHERE id=1' at line 1
Tried all sorts with it and it just wont ave it, dont think its anything to do with the actual content of the vars used to update, infact im just not sure, any help would be great...
Bit of a daft way around it but never the less, it works, im happy n with the final intended output the user should be happy but thanks anyways, let me know if u want a live view of what im doing
function updatedb($pagename){
global$PHP_SELF;
$dbuser="****";
$dbpass="xxx";
$db="gdon_contents";
$link=mysql_connect("localhost",$dbuser,$dbpass);
mysql_select_db($db,$link);
$dbresult=mysql_query("SELECT * FROM page$pagename");
$finalrow=mysql_num_rows($dbresult);
$field=mysql_fetch_array($dbresult);
for($z=1;$z<=$finalrow;$z++){
$udcontent="content$z";
$udshow="show$z";
$query="UPDATE page$pagename SET content='$GLOBALS[$udcontent]' WHERE id=$z";
if(!mysql_query($query,$link)){$dberror=mysql_error();echo $dberror;return false;};
}}
(Sorry my formatting is bad i know)
Everytime i add another field to update i.e:
$query="UPDATE page$pagename SET content='$GLOBALS[$udcontent]' show='$GLOBALS[$udshow]' WHERE id=$z";
I get the error on the output refering to the synatx:
You have an error in your SQL syntax near 'show='1' WHERE id=1' at line 1
Now it doesnt matter if i run a second query just to update the show field of the database as it returns the same... Any ideas
bye golly gosh watson i think youve cracked it...
(Will be back in ten with an updated)
Thanks!
Thanking you with the grace of a thousand camels my fellow brain, thats the wee hint ive been searching for, now my quest can continue, enjoy your coffee while i enjoy my efforts:
for the sake of, well i dont know but you can see the output here:
<snip>
The area in question was the edit page contents, if u select a page from the following list and make some changes ull see what the intention was for (remember to check the site view of the page you edited)
Thanks again with a thousand camels...
[edited by: jatar_k at 6:05 pm (utc) on Nov. 10, 2003]
[edit reason] no personal urls thanks [/edit]