PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 307,022 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,173 people online right now. Registration is fast and FREE... Join Now!




little problem

 

little problem

rkmalbz

3 Nov, 2009 - 03:06 PM
Post #1

New D.I.C Head
*

Joined: 10 Aug, 2009
Posts: 26


My Contributions
hello guys sorry but i have this problem which as i trace the code it seems correct..but it does not work..im new to php & mysql..this is my code by the way..
CODE

<?php

                if (isset($_POST[save])==true) {

                      if ($_POST[entryname]!="") {

                      $sql = "UPDATE newsfeeds SET entryname = '$_POST[entryname]' where newsid = $field[0]";

                      $result = mysql_query($sql);

                      echo "<script>self.location='news.php?newsarticle=$id'</script>";

                      } else {
                        echo "sorry unable to save the changes";
                          //echo "<script>";
                          //echo "alert('Unable to Save the changes.')";
                          //echo "</script>";
                      }
                }

                $sql = "select newsid,entryname,entrydesc from newsfeeds where newsid = $id";
                $result = mysql_query($sql);
                $field = mysql_fetch_array($result);

                    echo "<tr>
                            <td style='width:100px;'>News Entry&nbsp;&nbsp;</td>
                            <td><input type='text' value='$field[entryname]' name='name' /><br/></td>
                          <tr>
                          <tr>
                            <td valign='top'>News Description&nbsp;&nbsp;</td>
                            <td><textarea style='width:350px;height:150px' name='entrydesc'>$field[entrydesc]</textarea></td>
                          <tr>
                          <tr>
                            <td colspan=2 align=right><input type='submit' name='save' value='Save'/></td>
                          </tr>";

            ?>


it wont do some changes to mysql database...please help..

User is offlineProfile CardPM
+Quote Post


William_Wilson

RE: Little Problem

3 Nov, 2009 - 03:58 PM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,667



Thanked: 97 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
can you be more specific about the problem?

While I"m posting, you don't need to add ==true to your if statements. If the method returns a boolean it will be used and comparison to another boolean is unnecessary.
User is offlineProfile CardPM
+Quote Post

SeiferMaster

RE: Little Problem

3 Nov, 2009 - 06:02 PM
Post #3

New D.I.C Head
*

Joined: 28 Oct, 2009
Posts: 19



Thanked: 2 times
My Contributions
Add single quotes to your $_POST variables.
User is offlineProfile CardPM
+Quote Post

felixtgomezjr

RE: Little Problem

4 Nov, 2009 - 05:01 AM
Post #4

New D.I.C Head
Group Icon

Joined: 4 Nov, 2009
Posts: 42



Thanked: 3 times
Dream Kudos: 50
My Contributions
On your line

CODE
$sql = "UPDATE newsfeeds SET entryname = '$_POST[entryname]' where newsid = $field[0]";


try to check if field[0] has a value. Try debugging it by putting echo $sql after the line above and just to stop the execution of other lines, put exit() after the echo $sql.

Run the script and see if the UPDATE statement is complete and that there is value for field[0].

If in case you have done the above temporary modification but the exit() function was not executed, it means you have a logical problem with your IF Condition/s.

I hope that helps. See my PHP tutorials at Shoutbux
User is offlineProfile CardPM
+Quote Post

rkmalbz

RE: Little Problem

4 Nov, 2009 - 05:57 AM
Post #5

New D.I.C Head
*

Joined: 10 Aug, 2009
Posts: 26


My Contributions
thank you guys for the help i got it working now..anime1.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 08:09AM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month