Jump to content

Riyoku

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

About Riyoku

  • Birthday 07/26/1985

Contact Methods

  • Website URL
    http://

Profile Information

  • Gender
    Not Telling
  • Location
    Nunya

Riyoku's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [!--quoteo(post=354257:date=Mar 12 2006, 02:09 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 12 2006, 02:09 PM) [snapback]354257[/snapback][/div][div class=\'quotemain\'][!--quotec--] Can you post some more of your code? One statement out of context is not a help. That being said, I would change your code to be: [code]<?php $q = "UPDATE news SET `type`='$p_type', `title`='$p_title', `month`='$p_month', `day`='$p_day', `year`='$p_year', `body`='$p_body', `by`='$p_by' WHERE id='$n_id'"; echo '<pre> Query: ' . $q . '</pre><br />'; // for debugging $rs = mysql_query($q) or die('Problem with query: ' . $q . '<br />' . mysql_error()); ?>[/code] Ken [/quote] Oh, I'm sorry. I thought my problem was with just that statement so I didn't include more... [code]<?php include "db.php"; $n_id = $_GET['id']; $result=mysql_query("SELECT * FROM news WHERE id='$n_id'") or die("<b>Query error : </b>". mysql_error()); if (($REQUEST_METHOD=='POST')) { $p_type = $_POST['p_type']; $p_title = $_POST['p_title']; $p_month = $_POST['p_month']; $p_day = $_POST['p_day']; $p_year = $_POST['p_year']; $p_body = $_POST['p_body']; $p_by = $_POST['p_by']; $q = "UPDATE news SET `type`='$p_type', `title`='$p_title', `month`='$p_month', `day`='$p_day', `year`='$p_year', `body`='$p_body', `by`='$p_by' WHERE id='$n_id'"; echo '<pre> Query: ' . $q . '</pre><br />'; // for debugging $rs = mysql_query($q) or die('Problem with query: ' . $q . '<br>' . mysql_error());} else {while($row = mysql_fetch_array( $result )) { $f_type = $row['type']; $f_title = $row['title']; $f_month = $row['month']; $f_day = $row['day']; $f_year = $row['year']; $f_body = $row['body']; $f_by = $row['by'];?> <!--FORM--> <form action="nedt.php" method="post"><table align="center"> <tr><td><b>Type</b></td> <td><select style="width:188" name="p_type">     <option value="news">News</option>     <option value="updt">Update</option>     <option value="rmnr">Reminder</option></select></td></tr> <tr><td><b>Title</b></td><td><input type="text" style="width:188" name="p_title" value="<?echo $f_title;?>"></td></tr> <tr><td><b>Date</b></td>     <td><input type="text" style="width:60" name="p_month" value="<?echo $f_month;?>">     <input type="text" style="width:60" name="p_day" value="<?echo $f_day;?>">     <input type="text" style="width:60" name="p_year" value="<?echo $f_year;?>"></td></tr> <tr><td colspan=2><textarea style="width:226" name="p_body"><?echo $f_body;?></textarea></td></tr> <tr><td><b>Sign</b></td><td><input type="text" style="width:188" name="p_by" value="<?echo $f_by;?>"></td></tr> <tr><td colspan=2 align="right"><input type="submit" value="Submit"><input type="reset" value="Reset"></td></tr> </table></form> <? }} ?>[/code] It's retrieving the info from a form on the same page :P EDIT - added the whole thing just to be sure... and I THINK I figured out the problem thanks to your error retrieval - it isn't passing the ID along with the form! [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Query: UPDATE news SET `type`='news', `title`='Test', `month`='01', `day`='01', `year`='06', `body`='blah blah', `by`='Riyoku' WHERE id=''[/quote] would a hidden field do it? EDIT AGAIN - Apparently, it would! WOOOOOO! Thank you again for your help! Without your input, I would have never figured out where I went wrong. :3 *finishes up her pages now that she's got all the functions figured out. X3* <3
  2. Yes, me again, sorry ^^" Okay, mabey I've got the error retreival set up incorrectly? I don't know. What I do know is when I hit submit - the page claims it was successful. But when I go to retrieve the data later - it's completely unchanged. I've tried the code in the library but not only can I not.. understand it*so ashamed* but it causes HUGE strain on my website(at least I think it does, it takes about a minute to load a page right after I tried it) and gives me errors anyway... ._. So I switched back to the code I was using before. [code]mysql_query("UPDATE news SET `type`='$p_type', `title`='$p_title', `month`='$p_month', `day`='$p_day', `year`='$p_year', `body`='$p_body', `by`='$p_by' WHERE id='$n_id'") or die("<b>Update error : </b>". mysql_error());[/code] I can't post the error I'm getting as it wont give me one with that code. All I can say is I'm stumped that it just plain doesn't work... >>" Thanks again to the people who helped me last time. I learned my lesson, to set my pride aside and let people help - saves me a lot of time and frustration - and I can learn better that way too. Can't learn if I have no clue where I'm going wrong. EDIT - Sorry, I realised I left out a bit of information on my table and where the info is comming from. The table name is news and it has 8 rows; id(auto-number), type, title, month, day, year, body, and by. The new information is being retrieved by a form on the page. I'm only including the update statement as I'm assuming that's where the problem origonates.
  3. [!--quoteo(post=353382:date=Mar 9 2006, 03:48 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 9 2006, 03:48 PM) [snapback]353382[/snapback][/div][div class=\'quotemain\'][!--quotec--] "by" is a reserved word to MySQL, so surround it with backticks: [code]<?php mysql_query("insert into news(type, title, month, day, year, body, `by`) values('$type', '$title', '$month', '$day', '$year', '$body', '$by')") or die("Insert error : ". mysql_error()); ?>[/code] Ken [/quote] Oh... my.... -GLEEEEEEEE- you.. you... you're right, you're right! I had no clue about that... I should just re-name it anyway to "author" or "admin" as soon as possible. But jeeze! It went through! With correct data and everything! I'm sorry, it's just... hours and hours and such... and now I finally have my answer. I owe you big time, and I should really have sucked up my pride and come here to begin with... at least I will next time I'm stuck instead of staring at the same string of code for hours... o_o Do answered topics get locked?
  4. updated code to - [code]<?php include "db.php"; $type = $_POST['type']; $title = $_POST['title']; $month = $_POST['month']; $day = $_POST['day']; $year = $_POST['year']; $body = $_POST['body']; $by = $_POST['by']; mysql_query("insert into news(type, title, month, day, year, body, by) values('$type', '$title', '$month', '$day', '$year', '$body', '$by')") or die("Insert error : ". mysql_error()); ?>[/code] error changed to - [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Insert error : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'by) values('news', 'testing', '03', '09', '06', 'testing', 'riy[/quote] Thank you for the fast help, I wish it wasn't still fighting me though. But I'm sure your suggestion just prevented a problem I was/would be having at some point anyway. X3
  5. I'm... a complete idiot. I've spent hours upon hours searching across google for an answer to this(and of course the websites it has brought up) and even tried implementing a code a friend had made me several years ago (following it as a basic guideline) for the same website - that worked, but only with what they gave it to me for. >> What I'm trying to do is make a small basic control panel that only I will have access to. I've got the html done, but now I'm doing the PHP. I'm trying to keep the php code very basic so it will be at my level of knowledge. Roadblock though. I've managed to get my first control panel form to access my database(MySQL), I'm very sure of this as at the bottom of the form, I've programmed it to list all items already in my "news" table of my database. The problem is however, something seems to be wrong with my insert statement for the form... it's hitting a brickwall somewhere and every website just tells me to do it the way I already am. Enough with trying to describe my perdicament, here comes the facts. The table I'm using is called "news" - it has a total of 8 fields; id, type, title, month, day, year, body, and by. The code I'm using to insert is such - [code]<?php include "db.php"; $type = $_POST['type']; $title = $_POST['title']; $month = $_POST['month']; $day = $_POST['day']; $year = $_POST['year']; $body = $_POST['body']; $by = $_POST['by']; mysql_query("insert into news(type, title, month, day, year, body, by) values('$type', '$title', '$month', '$day', '$year', '$body', '$by')") or die("Insert error : ". mysql_error()); ?>[/code] The error I'm receiving says - [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Insert error : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'by) values('news', 'testing', '03', '09', '06', 'testing', 'riy[/quote] My host is avahost, not sure if that helps.... If you need more information from me, please poke me and let me know. Any and all help is vital and greatly appreciated. EDIT - Updated code and quote, thank you for the fast help. It's still being stubborn though ^^"
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.