Jump to content

solon

Members
  • Posts

    214
  • Joined

  • Last visited

    Never

Everything posted by solon

  1. Try bspace's approach. remove the "OR" from your queries and implode it later. But one thing you should do is: echo $query; to see exactly what your query looks like and find the error.
  2. you have to try and use something like the following: $query = "SELECT * FROM database WHERE "; if($city != "") { $query .= "city LIKE '%$city%' OR"; } if($name != "") { $query .= " name LIKE '%$name%' OR"; } and so on... to complete the query in that way, for the variables that have values in them. And then execute the query command. Because when the value is empty it show all results if you use "LIKE".
  3. The error "Undefined index id" is referring to the $_GET['id'] variable. since you don't sent anything using the GET method it comes up us undefined. You can edit that and line and use the following: <span class="date"><?php include"header.php"; if(isset($_GET['id']) //CHECK IF GET ID IS SET ELSE GET IT FROM HIDDEN FIELD IN THE FORM { $topicid=$_GET['id']; } else { $topicid=$_POST['id']; } $sql="SELECT*FROM topics WHERE topicsID=$topicid"; $result=mysql_query($sql) or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo"{$row['topics_date']}"; } ?></span> </p> </div> <h3>Comments:</h3> <table> <tr class="row-a"> <td class="first"></td> <td> <?php include"header.php"; if(isset($_POST['submit'])) { $comment=mysql_real_escape_string(trim($_POST['comment'])); $name=mysql_real_escape_string(trim($_POST['name'])); if($comment!=='' && $name!=='') { $ins="INSERT INTO post(post_content,post_by)VALUES('$comment','$name')"; mysql_query($ins) or die(mysql_error()); $sql="SELECT post_content,post_by FROM post ORDER BY topicsID"; $result=mysql_query($sql)or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo"<strong>{$row['post_by']}</strong>: {$row['post_content']}"."</br>"; } } } ?></td> </tr> </table> <h3>Post your comments here</h3> <form action='<?php $_SERVER['PHP_SELF'];?>' method='post'> <textarea name="comment" id="content" style="width:400px;height:50px;background-color:#D0F18F;color:#000000;font:15px/20px cursive;scrollbar-base-color:#638E0D;"></textarea> <br /> Name:<input type="text"name="name"/> <input class="button" type="submit"name="submit"value="submit" /> <input type="hidden" name="id" value="<?php echo $topicid; ?>" /> //THIS LINE IS A HIDDEN FIELD SAVING THE TOPIC ID FOR USE AFTER THE FORM IS SUBMITED </p> </form> <br />
  4. Try it now (there was a syntax error in the query): <h3>Comments:</h3> <table> <tr class="row-a"> <td class="first"></td> <td> <?php include"header.php"; if($_POST['submit']) { $post = $_POST["comment"]; $by = $_POST["name"]; $add = "INSERT INTO `post` values(`post_content`,`post_by`) ('$post','$by')"; $add_values = mysql_query($add) or die(mysql_error()); } $sql="SELECT post_content,post_by FROM post ORDER BY topicsID"; $result=mysql_query($sql)or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo"<strong>{$row['post_by']}</strong>: {$row['post_content']}"."</br>"; } ?> </td> </tr> </table> <h3>Post your comments here</h3> <form action='<?php $_SERVER['PHP_SELF']; ?>' method='post'> <textarea name="comment" id="content" style="width:400px;height:50px;background-color:#D0F18F;color:#000000;font:15px/20px cursive;scrollbar-base-color:#638E0D;"></textarea> <br /> Name:<input type="text"name="name"/> <input class="button" type="submit"name="submit"value="submit" /> </p> </form> It should work now
  5. Try the following (change the query to match your table and values <h3>Comments:</h3> <table> <tr class="row-a"> <td class="first"></td> <td> <?php include"header.php"; if($_POST['submit']) { $post = $_POST["comment"]; $by = $_POST["name"]; $add = "INSERT INTO `post` values(`post_content`,`post_by`,) ('$post','$by')"; $add_values = mysql_query($add) or die(mysql_error()); } $sql="SELECT post_content,post_by FROM post ORDER BY topicsID"; $result=mysql_query($sql)or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo"<strong>{$row['post_by']}</strong>: {$row['post_content']}"."</br>"; } ?> </td> </tr> </table> <h3>Post your comments here</h3> <form action='<?php $_SERVER['PHP_SELF']; ?>' method='post'> <textarea name="comment" id="content" style="width:400px;height:50px;background-color:#D0F18F;color:#000000;font:15px/20px cursive;scrollbar-base-color:#638E0D;"></textarea> <br /> Name:<input type="text"name="name"/> <input class="button" type="submit"name="submit"value="submit" /> </p> </form> I hope this helps
  6. Excellent!! Thank you very much cssfreakie .
  7. Great, i did not know that could be done without positioning. Although now that you mention it , it's logical. I'll have to use margins and paddings for spacing between elements though right?
  8. Thanks cssfreakie, i will try that.
  9. Hey guys i have a problem with one of my designs. I have this page designed using html/css with only div's and at the bottom of the page it show a large empty space. I read somewhere that the problem has to do with using position:relative; but i couldn't resolve the problem. Any one has any ideas as to why this is happening? By the way the code has passed the validation of w3c. (http://validator.w3.org/check?uri=http%3A%2F%2Fmkwebcy.com%2Falboro%2F) This is the link to the test page so you can see the problem as well as the code: http://mkwebcy.com/alboro/ Thanks in advance Solon
  10. Just do the following: When echoing a onclick() event in your code you dont need to do anything different than what you do when echoing lets say 'name' pr any other attribute name of a tag. echo "<tr><td>WrkComp</td><td><input type='checkbox' onClick='show()' name='WrkComp[]' value='DEP' '.$checked.' '.$Disabled.'/></td>";
  11. In that case i believe you should use sessions. When a user logs in (after the username and password are correct based on your db) you should have something like: session_start(); $_SESSION['user'] = 1; //or $_SESSION['user'] = $user_id; //which you get from your db table now if you do that in the login process page then you can have this in your homepage: session_start(); if(isset($_SESSION['user'])) { //show Logout link and user info } else { //show your login form }
  12. You could use session variables to store the values along the way. for example: page 1 form will POST the info of the completed fields to page 2 and to store them in a session variable you do the following: session_start(); $_SESSION['name'] = $_POST['name']; //... //... //etc... And for page 2 you do the same thing in page 3
  13. Try this: unset($eyeColorArray); $eyeColorArray = array('Black','Blue','Brown','Green','Grey','Hazel','Other'); echo "<select>"; //you missed the select tags foreach($eyeColorArray as $ectemp) { echo('<option value="' . $ectemp . '"> ' . $ectemp . ' </option>'); } echo "</select>"; //closing tags
  14. Hey djscoop, could you provide us with some more database information? how does you script store the votes in the db? if possible show us the structure of your database tables to see if there is another way of extracting the information you want with a mysql query!
  15. From where do you get the value you want to edit? Database? To get the value from your database table you need a query. As soon as you get the value just do this: <textarea><?php echo $value_from_database; ?></textarea> That will show the variable as the text in the text area
  16. <?php if (isset($_GET['edit']) && $_GET['edit'] == 'textupdate') { echo '<a href= "'.$_SERVER["PHP_SELF"].'"?edit=textupdate" id="'.$_GET['id'].'" >Edit</a>}'; } ?>
  17. your code seems fine. i dont know what the problem might be! If someone else is watching this thread and has an idea... but if it works with $_POST i think you should do it that way
  18. could you post the complete code? cause this does not seem to be a problem on the operators
  19. no... well at least it shouldn't. When the $_POST variable is empty it means it was not set so !isset($_POST) will work! and yes white space would probably set the variable.
  20. well what if you do the check on $_POST['name'] and if the statement is not empty set $Name = $_POST['name'] ? like: if(!isset($_POST['name'])) { //redirect here } // if it is set $Name = $_POST'name'];
  21. By the way why do you need to check the variable $Name and not the $_POST['name']? is there a reason for that?
  22. Also i tested this code and it works: First try this to see that the $Name is really set and what happens: <?php error_reporting(E_ALL); $IP=$_SERVER['REMOTE_ADDR']; $Date=date('d/m/Y'); $proID=$_GET['proID']; $ref=$_GET['ref']; //$Name variable is set to test $Name="test"; //$Email variable is set to testemail $Email="testemail"; $Country=$_POST['Country']; $Username=$_POST['Username']; $Password=$_POST['Password']; $Con_Password=$_POST['Con_Password']; if(!isset($Name)) { header ('Location: reenter.php'); exit(); } if(!isset($Email)) { header ('Location: reenter.php'); exit(); } echo $Name; ?> you will get "test" displayed and then this: <?php error_reporting(E_ALL); $IP=$_SERVER['REMOTE_ADDR']; $Date=date('d/m/Y'); $proID=$_GET['proID']; $ref=$_GET['ref']; //$Name variable is not set $Name; //$Email variable is not set $Email; $Country=$_POST['Country']; $Username=$_POST['Username']; $Password=$_POST['Password']; $Con_Password=$_POST['Con_Password']; if(!isset($Name)) { header ('Location: reenter.php'); exit(); } if(!isset($Email)) { header ('Location: reenter.php'); exit(); } echo $Name; ?> you will be redirected
  23. well for the last piece of code provided you are missing a semicolon ( ; ) and you must have error reporting off. try this: <?php error_reporting(E_ALL); if(!isset($_POST['Name'])) { echo "no values set"; } else echo $_POST['Name']; ?>
×
×
  • 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.