942,778 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 600
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Oct 29th, 2009
0

Pleas help

Expand Post »
it say theat he error is in line 16 i dont no wat error is plea help




PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. if($_POST['post'])
  4. {
  5.  
  6. //gat data
  7. $title = $_POST['title'];
  8. $body = $_POST['body'];
  9. //chec fot existance
  10. if ($title&&$body)
  11. {
  12. mysql_connect("localhost","root","")or die(mysql_error());
  13. mysql_select_db("dan")or die (mysql_error());
  14.  
  15. $date = date ("Y-m-d")
  16. //adaugarea inoutati
  17. $insert = mysql_query("INSERT INTO n VALUES ('','$title','$body','$date')") or die (msql_error());
  18. die ("Noutatea dumneavoastra nu a fostr adaugata");
  19. }
  20. else
  21. echo "Intrduceti va rog Informatia<p>";
  22. }
  23.  
  24.  
  25. ?>
  26. <Form action="post.php"method='post'>
  27. Title:<br>
  28. <input type='text' name='title'><p>
  29. Body:<br>
  30. <textarea rows="6"cols='35' name = 'body' ></textarea>
  31. <p>
  32. <input type="submit" name='post' value='Adauga' >
  33. <hr>
Last edited by Ezzaral; Oct 29th, 2009 at 1:37 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dan1992 is offline Offline
62 posts
since Oct 2009
Oct 29th, 2009
0
Re: Pleas help
Do this -
if (isset($title) && isset($body))
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Oct 29th, 2009
0
Re: Pleas help
Also:

$insert = mysql_query("INSERT INTO n VALUES ('','$title','$body','$date')") or die (msql_error());
Should be:

$insert = mysql_query("INSERT INTO n VALUES ('','$title','$body','$date')") or die (mysql_error());
Last edited by Froger93; Oct 29th, 2009 at 5:12 am.
Reputation Points: 11
Solved Threads: 6
Junior Poster in Training
Froger93 is offline Offline
74 posts
since Sep 2009
Oct 29th, 2009
0
Re: Pleas help
Quote ...
php Syntax (Toggle Plain Text)
  1. $date = date ("Y-m-d")
The date function needs a timestamp argument as the second argument and you should terminate this line.
php Syntax (Toggle Plain Text)
  1. date("argument 1",time());
Google for more info on how to use the date function
Reputation Points: 11
Solved Threads: 18
Junior Poster
sureronald is offline Offline
139 posts
since May 2008
Oct 29th, 2009
0
Re: Pleas help
thx for this but, is the same problem
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dan1992 is offline Offline
62 posts
since Oct 2009
Oct 29th, 2009
0
Re: Pleas help
Parse error: syntax error, unexpected T_VARIABLE in D:\Dan\web\bundle\xampp\xampp\htdocs\news\post.php on line 16
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dan1992 is offline Offline
62 posts
since Oct 2009
Oct 29th, 2009
0
Re: Pleas help
use the code tags, its not even clear which is the line16.
and try this -
PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. if(isset($_POST['submit']) && $_POST['submit'] != '' )
  4. {
  5. //gat data
  6. $title = $_POST['title'];
  7. $body = $_POST['body'];
  8. //chec fot existance
  9. if ($title != '' || $body != '')
  10. {
  11. mysql_connect("localhost","root","")or die(mysql_error());
  12. mysql_select_db("dan")or die (mysql_error());
  13.  
  14. $date = date ("Y-m-d")
  15. //adaugarea inoutati
  16. $insert = mysql_query("INSERT INTO n VALUES ('','$title','$body','$date')") or die (mysql_error());
  17. die ("Noutatea dumneavoastra nu a fostr adaugata");
  18. }
  19. else{ echo "Either title or body is blank";}
  20. }
  21. else
  22. echo "Intrduceti va rog Informatia<p>";
  23. }
  24.  
  25.  
  26. ?>
  27. <Form action="" method='post'>
  28. Title:<br>
  29. <input type='text' name='title' id="title"><p>
  30. Body:<br>
  31. <textarea rows="6"cols='35' name = 'body' id="body" ></textarea>
  32. <p>
  33. <input type="submit" name='submit' value='Adauga' >
  34. <hr>
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Oct 29th, 2009
0
Re: Pleas help
Ignore the previous post, your code there did not have proper html even.
PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. if(isset($_POST['submit']) && $_POST['submit'] != '' )
  4. {
  5. //gat data
  6. $title = $_POST['title'];
  7. $body = $_POST['body'];
  8. //chec fot existance
  9. if ($title != '' || $body != '')
  10. {
  11. mysql_connect("localhost","root","")or die(mysql_error());
  12. mysql_select_db("dan")or die (mysql_error());
  13.  
  14. $date = date ("Y-m-d")
  15. //adaugarea inoutati
  16. $insert = mysql_query("INSERT INTO n VALUES ('','$title','$body','$date')") or die (mysql_error());
  17. die ("Noutatea dumneavoastra nu a fostr adaugata");
  18. }
  19. else{ echo "Either title or body is blank";}
  20. }
  21. else
  22. echo "Intrduceti va rog Informatia<p>";
  23. }
  24.  
  25.  
  26. ?>
  27. <html>
  28. <title></title>
  29. <body>
  30. <Form action="" method='post'>
  31. Title:<br>
  32. <input type='text' name='title' id="title">
  33. Body:<br>
  34. <textarea rows="6"cols='35' name = 'body' id="body" ></textarea>
  35. <br>
  36. <input type="submit" name='submit' value='Adauga' >
  37. </Form>
  38. </body>
  39. </html>
Last edited by network18; Oct 29th, 2009 at 9:33 am.
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009
Oct 29th, 2009
0
Re: Pleas help
bu this can be the problem with data base ?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dan1992 is offline Offline
62 posts
since Oct 2009
Oct 29th, 2009
0
Re: Pleas help
this can be a problem with data base becos i tried theat wat you writh an is the same error (
sry for my engles i'm learning englesh just 3 eares
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
dan1992 is offline Offline
62 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Help with writing/understanding foreach
Next Thread in PHP Forum Timeline: Out parameter does not work with mysql.? Help me





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC