Jump to content

raggy99

Members
  • Posts

    18
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

raggy99's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you, i have been able to see the data. However now i have a syntex error. I have looked through the code and all the " and ; looks ok to a novice. line 1 is <!doctype html> Code <!doctype html> <html> <head> <meta charset="utf-8"> <title>Update PI</title> </head> <body> <?php include 'db.php'; $query = "SELECT * FROM PI WHERE PIID=$_GET[PIID]"; $result = mysql_query($query) or die(mysql_error()); ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table width="600"> <tr> <?php while($row = mysql_fetch_array($result)) { $PIName=$row['PIName']; $MonthYear=$row['MonthYear']; $Status=$row['Status']; ?> <td>PI Name</td> <td><input type="text" name="PIName" value="<? echo $PIName; ?>"><br></td> </tr> <tr> <td>Month-Year</td> <td><input type="text" name="MonthYear" value="<? echo $MonthYear; ?>"><br></td> </tr> <tr> <td>Status</td> <td><input type="text" name="Status" value="<? echo $Status; ?>"><br></td> </tr> <tr> <td>Click Save</td> <td><input name="update" type="Submit" value="Save"></td> </tr> </table> <?php } ?> <?php if(isset($_POST['update'])); { $PIName=$_POST['PIName']; $MonthYear=$_POST['MonthYear']; $Status=$_POST['Status']; $sql=mysql_query ("UPDATE PI SET PIName='$PIName', MonthYear='$MonthYear', Status='$Status' WHERE PIID='PIID'"); $retval = mysql_query($sql); if(! $retval ) { die('Could not update data: ' . mysql_error()); } echo "Updated data successfully"; } ?> </body> </html> What have I missed
  2. I have amended the code new code <!doctype html> <html> <head> <meta charset="utf-8"> <title>Update PI</title> </head> <body> <?php include 'db.php'; $query = "SELECT * FROM PI"; $result = mysqli_query($query) or die(mysqli_error()); ?> <form action="<?php $_PHP_SELF ?>" method="Post"> <?php while($row = mysqli_fetch_array($result)) { $PIname=$row['PIname']; $monthyear=$row['monthyear']; $status=$row['status']; ?> <input type="hidden" name="PIupdate" value="<? echo $PIID; ?>"> PI Name: <input type="text" name="PIname" value="<? echo $PIname; ?>"><br> PI Date: <input type="text" name="monthyear" value="<? echo $monthyear; ?>"><br> PI Status: <input type="text" name="status" value="<? echo $status; ?>"><br> <input type="Submit" value="Save"> <?php if(isset($_POST['update'])) { $PIname=$_POST['PIname']; $monthyear=$_POST['monthyear']; $status=$_POST['status']; $sql=mysqli_query ("UPDATE PI SET PIName='$PIname', MonthYear='$monthyear', Status='$status' WHERE PIID='$PIID'"); $retval = mysqli_query($sql); if(! $retval ) { die('Could not update data: ' . mysqli_error()); } echo "Updated data successfully"; }} ?> </body> </html> i was able to get the error message from the log. [09-Jan-2016 10:23:22] PHP Warning: mysqli_query() expects at least 2 parameters, 1 given in /home3/public_html/pitaker/admin/updatepi.php on line 12 [09-Jan-2016 10:23:22] PHP Warning: mysqli_error() expects exactly 1 parameter, 0 given in /home3/public_html/pitaker/admin/updatepi.php on line 12 Regarding live site. it is not actually a live site... as in people going to it. it's just my domain. However i do understand that if it was a live site, i would have a production instance and a testing instance. maybe even a dev instance. Thank you for your assistance in helping a big noob.
  3. no, php is installed and working. I'm working on a live site. I have been able to pull the data, however when i created the update page I get a 500 error. I am able to store other data to other tables. and to this table.
  4. Hi All, I'm trying to update a record. O have been following tutorials, however now i'm getting a 500 error. not sure why. I was getting the page to disply at one stage with do data from sql. Now nothing. I hope you can help. Original Data (works fine) <!doctype html> <html> <head> <meta charset="utf-8"> <title>View PI</title> </head> <body> <?php include 'db.php'; $query = "SELECT * FROM PI WHERE Status ='Open' OR Status ='Locked' ORDER BY PIName"; $result = mysql_query($query); echo "<table width='400px' border='1'>"; echo "<tr> <th>PI Name</th> <th>Date</th> <th>Status</th> <th>Edit</th> </tr>"; while($row=mysql_fetch_array($result)) { echo "<tr><td align='center'>"; echo $row['PIName']; echo "</td><td align='center'>"; echo $row['MonthYear']; echo "</td><td align='center'>"; echo $row['Status']; echo "</td><td align='center'>"; echo "<a href=\"updatepi.php?PIID=" . $row['PIID'] . "\">Edit</a>"; echo "</td></tr>"; } echo "</table>"; ?> </body> </html> Update data (500 error) <html> <?php include 'db.php'; $query = "SELECT * FROM PI WHERE PIID ='$PIID'"; $result = mysql_query($query); $PI = mysql_fetch_array($result) or die(mysql_error()); mysql_close(); $i=0; While($i< $num) { $PIname=mysql_result($result,$PI,['PIname']); $monthyear=mysql_result($result,$PI,['monthyear']); $status=mysql_result($result,$PI,['status']); } ?> <body> <form action="" method="Post"> <input type="hidden" name="PIupdate" value="<? echo $PIID; ?>"> PI Name: <input type="text" name="PIname" value="<? echo $PIname; ?>"><br> PI Date: <input type="text" name="monthyear" value="<? echo $first; ?>"><br> PI Status: <input type="text" name="status" value="<? echo $status; ?>"><br> <input type="Submit" value="Save"> </form> </body> </html>
  5. Thank you. it works.
  6. Hello, Thanks for the quick reply. I made the change but it didn't seam to work. so i went hunting for a new tutorial and found what looks like a cleaner code.. I am now able to increase my autoid in the db, however now the other data does not post. form data <html> <head> <meta charset="utf-8"> <title>Create a Stocktakes</title> </head> <form action="processstocktake.php" name="createpi"> <table width="600" border="1"> <tbody> <tr> <td align="center" colspan="2">Create a Stocktake</td> </tr> <tr> <td width="200"> </td> <td> </td> </tr> <tr> <td>Stocktake Name</td> <td><input name="stocktakename" type="text" required="required" size="50"></td> </tr> <tr> <td>Date (Month-Year)</td> <td><input name="monthyear" type="text" required="required"></td> </tr> <tr> <td>Stocktake Status</td> <td><input name="status" type="text" value="Open"></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td><input type="reset"></td> <td align="right"><input type="submit"></td> </tr> </tbody> </table> </form> <body> </body> </html> <?php include 'db.php'; $stocktakename=$_POST['stocktakename']; $monthyear=$_POST['monthyear']; $active=$_POST['status']; mysql_query ("INSERT INTO Stocktakes(StocktakeID, StocktakeName, MonthYear, Active) VALUES (NULL, '$stocktakename', '$monthyear', '$active')") or die(mysql_error()); Echo"data inserted"; mysql_close(); ?> I think i'm missing something between the form and process script, however i even copied the name from the form to the processstocktake.php file. this is making me go insane.
  7. Hi All, I'm going stir crazy trying to find the error. I'm getting my "data inserted message". however it is not showing in phpmyadmin. P.S. I'm doing this project from scratch, with no real experience. I dabbled in php years ago. I think i stopped because i got frustrated that i could not get it to work. . Form Code <html> <head> <meta charset="utf-8"> <title>Create a Stocktakes</title> </head> <form action="processstocktake.php" name="createpi"> <table width="600" border="1"> <tbody> <tr> <td align="center" colspan="2">Create a Stocktake</td> </tr> <tr> <td width="200"> </td> <td> </td> </tr> <tr> <td>Stocktake Name</td> <td><input name="stocktakename" type="text" required="required" id="stocktakename" size="50"></td> </tr> <tr> <td>Date (Month-Year)</td> <td><input name="monthyear" type="text" required="required" id="monthyear"></td> </tr> <tr> <td>Stocktake Status</td> <td><input name="active" type="text" id="active" value="Active"></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td><input type="reset"></td> <td align="right"><input type="submit"></td> </tr> </tbody> </table> </form> <body> </body> </html> Database connection file, when i open this file it shows a blank screen, so password it is connecting <?php $connect=mysql_connect('localhost','Username@localhost','password','Username_DBbase'); if(mysqli_connect_error($connect)) { echo 'Failed to connect, check your username and/or password'; } ?> Post script <?php include ('db.php'); $stocktakename=$_POST['StocktakeName']; $monthyear=$_POST['MonthYear']; $active=$_POST['Active']; ("INSERT INTO Stocktakes(StocktakeName,MonthYear,Active) VALUES('$stocktakename','$monthyear','$active')") or die(mysql_error()); Echo"data inserted"; mysql_close(); ?> Most of the code above i got from tutorials and customised it for my needs. I hope you can assist. be gentle i'm new.
×
×
  • 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.