Jump to content

guidance51x

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Everything posted by guidance51x

  1. Thank you everyone for your help. I really appreciate it.
  2. Hey Everyone. I've been using a piece of code several times before and its worked fine but now (after updating my php version) I get an error. Heres the code: if(isset($_GET['id']) == TRUE){ if(is_numeric($_GET['id'])==FALSE) { $error = 1; } if($error == 1){ header("Location: " . $config_basedir); } else{ $validentry = $_GET['id']; } } else{ $validentry = 1; } The line with "if($error == 1){" gets flagged with an error saying: Notice: Undefined variable: error in C:\xampp\htdocs\sites\smd\index.php on line 8 I've used the code before with no problems and uploaded to my web server I also have no errors. What did I do wrong. I hope it isn't a seriously stupid error. Thanks in advance.
  3. OK! Everything fixed. Thanks a lot to everyone. props to PFMaBiSmAd
  4. When i submit the code it redirects to index.php and looks like nothing ever changed. The first thing i saw was this message on top of my script: Notice: Undefined index: submit in C:\xampp\htdocs\sites\smart\addtodo.php on line 20 when i try to submit something, the page 404's with this in the URL box: http://localhost/sites/web/%3Cbr%20/%3E%3Cb%3ENotice%3C/b%3E:%20%20Undefined%20variable:%20SCRIPT_NAME%20in%20%3Cb%3EC:%5Cxampp%5Chtdocs%5Csites%5Csmart%5Caddtodo.php%3C/b%3E%20on%20line%20%3Cb%3E43%3C/b%3E%3Cbr%20/%3E?id=1 I'm guessing it has a problem with $SCRIPT_NAME or ?id=1... Any help wit clarification?
  5. $SCRIPT_NAME refers to the script itself. the bottom half is the html of the form while the top half is the part processing the data
  6. When i run the script as a page and try to submit the fields, they dont get inserted into the dbase. No errors.
  7. thanks for the reply. unfortunately it seems that isnt the problem
  8. you could do something like this: $query = mysql_query($sql) $total = mysql_num_rows($query) while($row = mysql_fetch_assoc($query)){ //do whatever $current = $row['id']; // best practice to have an 'id' field for entries while($current > 0){ echo "<a href='previouspage.php?id=" . $current - 1 . "'>Previous</a>"; } while($current < $total){ echo "<a href='nextpage.php?id=" . $current + 1 . "'>Next</a>"; } } Hope this helps!
  9. Hello Everyone This is a basic script for posting to a database. I'm not sure why it doesn't work. Can anyone tell me why? <?php require('config.php'); if(isset($_GET['id']) == TRUE && isset($_GET['td'])==TRUE){ if(is_numeric($_GET['id'])==FALSE || is_numeric($_GET['td'])==FALSE) { $error = 1; } if($error == 1){ header("Location: " . $config_basedir); } else{ $validentry = $_GET['id']; $validtd = $_GET['td']; } } else{ $validentry = 0; } if($_POST['submit']) { $db = mysql_connect($dbhost,$dbuser,$dbpassword); mysql_select_db($dbdatabase, $db); if(!$db){ die('FAILED TO OPEN DATABASE:' . mysql_error()); } $sql = "INSERT INTO todo(id, topic, date, comment) VALUES (" . $validentry . ", '" . $_POST['topic'] . "', '" . $_POST['date'] . "', '" . $_POST['comment'] . "');"; $result=mysql_query($sql); if(!$result){ die('FAILED TO INPUT INTO DATABASE:' . mysql_error()); } header("Location: index.php?id=" . $validentry); } ?> <center> **All dates must be inputted in the YYYY-MM-DD format** <br> <br> <form action="<?php echo $SCRIPT_NAME . "?id=" . $validentry; ?>" method="post"> <table> <tr> <td>Topic</td> <td><input type="text" name="topic"></td> </tr> <tr> <td>Date</td> <td><input type="text" name="lname"></td> </tr> <tr> <td>Comment</td> <td><input type="text" name="address"></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="Submit Note"></td> </tr> </table> </form> </center>
×
×
  • 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.