28, May 2012

this page wont write to database - webmaster forum

 
Webdigity webmaster forums
[ 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
Instabuck - The easy way to sell digital products online

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



« Reply #20 on: Jan 24, 2006, 06: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 or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1525
6359 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #21 on: Jan 24, 2006, 07: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 : Canonical URL Links / Tags
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #22 on: Jan 25, 2006, 12:48:30 am »

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


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



« Reply #23 on: Jan 25, 2006, 01: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 or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #24 on: Jan 25, 2006, 01: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.";
}
?>


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



« Reply #25 on: Jan 25, 2006, 01: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 or twitter

Last blog : Butterfly Marketing 2.0
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #26 on: Jan 25, 2006, 01: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


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



« Reply #27 on: Jan 25, 2006, 02: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 or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1525
6359 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #28 on: Jan 25, 2006, 02:23:33 am »

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


Last blog : Canonical URL Links / Tags
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #29 on: Jan 25, 2006, 07: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..


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


Gimme all your cookies!!!


« Reply #30 on: Jan 25, 2006, 10: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 : Canonical URL Links / Tags
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #31 on: Jan 25, 2006, 11:08:45 am »

$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, 11:10:17 am by Meth0d »


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


Gimme all your cookies!!!


« Reply #32 on: Jan 25, 2006, 11:20:13 am »

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 : Canonical URL Links / Tags
aka J Love
Community Supporter ?
Bill Gates is my home boy
*****
Gender: Male
Posts: 886
1148 credits
Members referred : 4



« Reply #33 on: Jan 25, 2006, 11:53:23 am »

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?


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


Gimme all your cookies!!!


« Reply #34 on: Jan 25, 2006, 12:21:06 pm »

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


Last blog : Canonical URL Links / Tags
Global Moderator
Internet Junkie
*****
Gender: Male
Posts: 1525
6359 credits
Members referred : 8


Gimme all your cookies!!!


« Reply #35 on: Jan 25, 2006, 06: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 : Canonical URL Links / Tags
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....

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?
May 28, 2012, 05:35:52 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!


Forum Statistics
Total Posts: 62.837
Total Topics: 11.030
Total Members: 21.452
Tutorials : 58
Resources : 929
Designs : 395
Latest Member: iplaytheme

111 Guests, 3 Users online :

13 users online today:




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