4, December 2008

this page wont write to database - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: this page wont write to database
« previous next »
Pages: 1 [2] Print

Author Topic: this page wont write to database  (Read 1370 times)
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8269
42601 credits
Members referred : 3



« Reply #20 on: Jan 24, 2006, 07:08:37 PM »

What's the problem here?

You know we can't help you if you don't tell what the problem is.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1523
6847 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #21 on: Jan 24, 2006, 08:14:23 PM »

Well, so far I can see that you have the ame problem as the last piece of code. You need to use the same if statement in this one too. But the name is "update" this time.


Last blog : Site of the Month - August 2007
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #22 on: Jan 25, 2006, 01:48:30 AM »

yes this page wont update the database either. that is the problem nik

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8269
42601 credits
Members referred : 3



« Reply #23 on: Jan 25, 2006, 02:38:29 AM »

Change your sql statement to this :

"UPDATE links set url = '$url', title = '$title', description = '$description' where id = '".$_GET[links]."'"

By the way this would be faster if you put a limit. Eg.

"UPDATE links set url = '$url', title = '$title', description = '$description' where id = '".$_GET[links]."' LIMIT 1"

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #24 on: Jan 25, 2006, 02:47:26 AM »

u are looking at wrong page, i am on a different one, link_mod.php:

Code:
<?
ob_start();
include("config.php");
if ($logged[username] && $logged[level] >= 2) 
{
// the user is logged in!  We continue...
if ($_POST['update'] != 'Update')
{
// the form hasn't been submitted.  We continue...
$data2 = mysql_query("SELECT * from users where username = '$logged[username]'");
$data2 = mysql_fetch_array($data2);
$urlid = $data2[urlid];
$data = mysql_query("SELECT * from links where id = '$urlid'");
$data = mysql_fetch_array($data);
// the above lines get the information so that it can be displayed in the html form.
echo("
<div align=\"center\"><form method=\"post\">
<table>

<tr>
<td valign=\"top\">Links Title: </td>
<td valign=\"top\"><input name=\"title\" type=\"text\" value=\"$data[title]\"></td>
</tr>
<tr>
<td valign=\"top\">Links URL: </td>
<td valign=\"top\"><input name=\"url\" type=\"text\" value=\"$data[url]\"></td>
</tr>
<tr>
<td height=\"85\" valign=\"top\">Description: <br> </td>
<td valign=\"top\"><textarea cols=\"30\" rows=\"5\" name=\"description\">$data[description]</textarea>
</td>
</tr>
<tr>
<td align=\"center\" colspan=2><input type=\"submit\" name=\"update\" value=\"Update\"></td>
</tr>
</table>
</form>
</div>");
}
else
{
$url = $_POST[url];
$title = $_POST[title];
$description = $_POST[description];
// the above lines set variables used below
$update = ("UPDATE links set url = '$url', title = '$title', description = '$description' where id = '$urlid'");
mysql_query($update) or die(mysql_error());
// updates the information in the database.
echo "Your link has been successfully updated."; 
}
}
else
{
// They aren't logged in!
echo "You have either not paid for your link to even submit it, or you are not logged in.";
}
?>

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8269
42601 credits
Members referred : 3



« Reply #25 on: Jan 25, 2006, 02:50:31 AM »

The first query may not work ( "SELECT * from users where username = '$logged[username]'" )

Change it to

"SELECT * from users where username = '".$logged[username]."'"

If you still have problem please also let us know the error message that you get

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #26 on: Jan 25, 2006, 02:55:15 AM »

i htink that query does work because it loads the right link in the form based on what user is logged in, and what URL ID they are assigned manually by me.. it says that it updates teh link but nothing happens

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8269
42601 credits
Members referred : 3



« Reply #27 on: Jan 25, 2006, 03:01:39 AM »

I can't figure it out.

Something that you should do is adding slashes to the post vaariables that you use.

eg. $url = addslashes (  $_POST[url] ) ; (instead of $url = $_POST[url]; )

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy or twitter Visit through proxy

Last blog : Free Unlimited Bandwith and disk space to good to be true?
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1523
6847 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #28 on: Jan 25, 2006, 03:23:33 AM »

I would say that your $urlid is not being set in the else part...


Last blog : Site of the Month - August 2007
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #29 on: Jan 25, 2006, 08:57:25 AM »

ya thats what i thought, that it wasnt correctly updating the right ID #.. any suggestions? i tried addslashes (nik) and still no luck..  but i will leave them there as u say it is better but for what reason im not sure..

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1523
6847 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #30 on: Jan 25, 2006, 11:25:49 AM »

$urlid is not being set when you are trying to do the update. You have to set it in the "else" part of the page.


Last blog : Site of the Month - August 2007
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #31 on: Jan 25, 2006, 12:08:45 PM »

$urlid as you see comes from a separate table where i pre-define this variable myself.. so how would i go about doing this? i am still learning the basics of php i am v-confused.. i tried creating new $update query = no luck, tried adding it to the current query = no luck..

edit: by the way after you help me figure this one out, i will send u 500 credits for your trouble Tongue
« Last Edit: Jan 25, 2006, 12:10:17 PM by Meth0d »

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1523
6847 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #32 on: Jan 25, 2006, 12:20:13 PM »

Take this code:

Code:
$data2 = mysql_query("SELECT * from users where username = '$logged[username]'");
$data2 = mysql_fetch_array($data2);
$urlid = $data2[urlid];

and place it in front of the "if" statement. This way you can use it for both the if and else parts.


Last blog : Site of the Month - August 2007
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 884
1636 credits
Members referred : 4



« Reply #33 on: Jan 25, 2006, 12:53:23 PM »

yep that fixed it and i should of known that, ill send u the credits now.. wondering if ud still be able to help me if i was to PM you in the future and pay credits each time?

Visit through proxy Visit through proxy Visit through proxy

Last blog : phpHaze 1.59.1 in Development
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1523
6847 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #34 on: Jan 25, 2006, 01:21:06 PM »

Thanks... sure I will help where I can!


Last blog : Site of the Month - August 2007
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1523
6847 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #35 on: Jan 25, 2006, 07:02:58 PM »

Another thing... why not set output buffering in the .htaccess file? Then you don't have to turn it on at the start of each page.


Last blog : Site of the Month - August 2007
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=1329
Tags : php html forums databases cms Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: 1 [2] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: this page wont write to database
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Dec 04, 2008, 12:30:18 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!





Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.