Jump to content

gristoi

Members
  • Posts

    840
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by gristoi

  1. always a pleasure
  2. Change you query and remove the brackets around the pid and you need to alias the count: the extra brackets in the query are terminating your script further on
  3. When you added the new column did you add the extra input code into the sql statement i.e shipped ='something' , and if not did you ensure that the field value for shipped in the table was set to null to allow a null input?
  4. Hi, like I stated previously your have some syntax errors within your mysql query. firstly, if you are joining tables together in a query then you need to use the concatenation operator '.' to prepend the tablename to the field name. In your query you were using a comma to do this. Secondly, you do not need to surround the fieldnames in the query with single quote marks, so posts.postid instead of 'posts'.'postid' is fine. You only need to use '' to surround the alias name of you fieldname - posts.postid AS 'ID' . There wil however be occasions when you do need to ensure there is not a conflict with reserved MYSQL words and for this you can surround the name with ``. I did miss some of the commas on your query before but it should look like this: SELECT posts.post_id AS 'id', posts.post_title AS 'title', LEFT(posts.post_body,'512') AS 'preview', posts.post_user AS 'user', DATE_FORMAT(posts.post_date,'%d/%m/%Y %H:%i:%s') AS 'date', comments.total_comments, DATE_FORMAT(comments.last_comment,'%d/%m/%Y %H:%i:%s') AS 'last_comment' FROM posts LEFT JOIN ( SELECT post_id, COUNT('comment_id') AS 'total_comments', MAX('comment_date') AS 'last_comment' FROM comments GROUP BY post_id ) AS comments ON posts.post_id = comments.post_id ORDER BY posts.post_date DESC; A bit of advice with working with your queries: to check whether the query is syntactically correct ( and works ) I always directly run my query in my mysql workbench / phpmyadmin panel or sql command line on my dev environment to ensure that it is working properly. If it is then that allows me to look elswhere for what could be causing the issue. Tools such as mysql workbench allow you to write and test your queries and will highlight if there is a syntax error in your query, very useful. The looping error you are getting is more than likely due to the syntax error in your query not returning a valid resource. Hope this helps
  5. Hi, not a my pc right now, but I can tell you that you can change the colour and look ofthe tables in the diagrams to anything you want in mysql WB.
  6. print($client->RetrieveArticles("Article")); Is incorrect, RetrieveArticles is returning an array. Try: $result = $client->RetrieveArticles("Article"); print_r($result); And see what it gives you
  7. you could try to use the EER diagram functionality in Mysql Workbench. The program is free and can be downloaded from http://wb.mysql.com/
  8. missing a semi colon on 2nd line. should be: require("includes/connection.php");
  9. I dont understand what you are on about. the issue you had was with while($row = mysql_fetch_assoc($out); <--- you had a semi colon and were missing a ')' So i fixed that and reported your code. So please read through you code before saying you already know. If you 'already knew' then you wouldnt have posted your issue on the forum
  10. SELECT posts.post_id AS 'id', posts.post_title AS 'title', LEFT(posts.post_body,'512') AS 'preview', posts.post_user AS 'user', DATE_FORMAT(posts.post_date,'%d/%m/%Y %H:%i:%s') AS 'date', comments.total_comments, DATE_FORMAT(comments.last_comment,'%d/%m/%Y %H:%i:%s') AS 'last_comment' FROM posts LEFT JOIN ( SELECT post_id, COUNT('comment_id') AS 'total_comments', MAX('comment_date') AS 'last_comment' FROM comments GROUP BY post_id ) AS comments ON posts.post_id = comments.post_id ORDER BY 'posts','post_date' DESC;
  11. try: <?php mysql_connect ("-","-","-") or die ('Error'); mysql_select_db ("-"); $out = mysql_query("SELECT * FROM guestbook ORDER BY id DESC"); while($row = mysql_fetch_assoc($out)) { $name = $row['name']; $email = $row['email']; $txt = $row['comment']; $msg = "Are you sure you want to delete"; /* @var $_REQUEST <type> */ if (isset($_REQUEST ["action"]) && $_REQUEST["action"] == "del") { $id = intval($_REQUEST['id']); mysql_query("DELETE FROM guestbook WHERE id=$id;"); echo "<action=index.php>"; } echo "<font face='verdana' size='1'>"; echo "<table border='0'> <tr><td>Name: ".$name."</td></tr>"." <tr><td>Email: ".$email."</td></tr> <tr><td colspan='2'>Comment:</td></tr> <tr><td colspan='2' width='500'><b>".$txt."</b></td></tr> <tr><td><a onclick=\"return confirm('.$msg.');\" href='index.php?action=del&id=".$row['id']."'><span class='red'>["."Delete"."]</span></a> </td></tr> </table><br />"; echo "<hr size='1' width='500' align='left'></font>"; } ?>
  12. I am afraid I am not completely understanding what you need to do. If you just need to redirect after the fields are valid then you could use <?elseif(isset($_POST['send'])):?> header('Location:insert.php'); <?endif?>
  13. can you post the table structure please
  14. try LEFT('posts'.'post_body','512') AS 'preview', instead of square brackets
  15. Can you show the ajax/validation.js file
  16. you need to set the action of your form, to tell it where to post the data to <form method="post" id="customForm" action="insert.php">
  17. Hi, sorry, I never had time to look over all of the code before. You have the email function in the wrong part of your script, all of the email code you have written needs to go directly after your update query and before the $URL =[\code] line. The errors you are getting is because it is sitting on a part of the script that hasn't been posted yet.
  18. It might not be throwing an error. It might be a logic problem where your code will never hit that loop. One way to test is to manually kill the script with the die('I am here'); place that firstly before you call the mail part. If you see 'I am here' then if loop has been entered. Then place it after the mail function and see if it is called again. Im sure you get the picture
  19. your going to need a mail server on your lamp stack. i use postfix for my localhost. Have a look at: http://askubuntu.com/questions/25833/is-there-a-simple-mail-server-i-can-install
  20. smtp_port in your php.ini
  21. try changing the outgoing port to the standard port 25 instead of 465
  22. you are trying to mail twice, once before you declare your headers. from line 145 change: mail($sEmailAddress, $sSubject, $sMessage, $sHeaders); $sMessage = "<p>Someone has edited the information below.</p><br> Location : {$_REQUEST['location']}<br>First Name : {$_REQUEST['fname']}<br>Last Name : {$_REQUEST['lname']}"; $sHeaders = "MIME-Version: 1.0\n"; $sHeaders .= "Content-type: text/html; charset=iso-8859-1\n"; $subject = "Please Review"; $sHeaders .= "To: Supervisor <$sEmailAddress>\n"; $sHeaders .= "From: The Database <sender email>\n"; if (mail($sEmailAddress, $sSubject, $sMessage, $sHeaders)) { echo "<center>An email has been sent to the supervisor for review"; } else { echo "This system is not working properly. Please contact a tech."; } To: $sMessage = "<p>Someone has edited the information below.</p><br> Location : {$_REQUEST['location']}<br>First Name : {$_REQUEST['fname']}<br>Last Name : {$_REQUEST['lname']}"; $sHeaders = "MIME-Version: 1.0\n"; $sHeaders .= "Content-type: text/html; charset=iso-8859-1\n"; $subject = "Please Review"; $sHeaders .= "To: Supervisor <$sEmailAddress>\n"; $sHeaders .= "From: The Database <sender email>\n"; $sendMail = mail($sEmailAddress, $sSubject, $sMessage, $sHeaders); if (sendMail) { echo "<center>An email has been sent to the supervisor for review"; } else { echo "This system is not working properly. Please contact a tech."; } also echo out $sMessage and $sHeaders to make sure you havent got anything escaping the string. If you are still getting no confirmation message then this part of the loop is not being entered on the page and you will need to do some fault finding to find where the script is stopping.
  23. i dont think this should stop it from working but on line 150 you have $subject instead of $sSubject . also, are you getting the expaected output onto the page? ie. An email has been sent to the supervisor for review
  24. try: <table border="1" cellspacing="1" align="center" bordercolor="#FFFFFF"> <tr> <td>Course Name</td> <td>Edit</td> <td>Submit</td> <td>Delete</td> </tr> <?php $query = "SELECT * FROM Courses "; $result = mysql_query ($query); if(mysql_num_rows($result)>0){ while($row = mysql_fetch_array($result)) { echo'<form action="editcourses.php" method="post">'; echo('<tr>' . '<td>' . $row['CourseName'] . '</td>' . '<td><input type="hidden" name="id" value="' . $row['ID'] . '"/><textarea name="coursenametext" rows="2"></textarea>' . '</td>' . '<td>' . '<input type="Submit" name="Submit" value="Submit">' . '</td>' . '<td>' . '<input type="Submit" name="Delete" value="Delete">' . '</td>' . '</tr>' '</form>'; ); } } if(isset($_POST['Submit'])) { $query1 = "UPDATE courses SET courseName = '".$_POST['coursenametext']."' WHERE ID = '".$_POST['id']."'"; $result1 = mysql_query ($query1); } if(isset($_POST['Delete'])) { $query1 = "Delete FROM courses WHERE ID = '".$_POST['id']."'"; $result1 = mysql_query ($query1); } ?> </table> and as for adding a new one, you just need to create a new form outside of the loop and name the button create etc......
  25. $sEmailAddress = '[email protected]'; is there a real email address called [email protected]?
×
×
  • 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.