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. 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.
  6. 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.
  7. I had the changes and it works 100%. I added the line, no errors came up on the webpage. will they show somewhere else?
  8. Hello all, my update page isn't updating the records. Can anyone tell me what i'm doing wrong? Apart from using dreamweaver. When the page opens it shows all the data, When I change the data it don't update. <?php define('DB_NAME', 'DB Name'); define('DB_USER', 'Username'); define('DB_PASSWORD', 'Password'); define('DB_HOST', 'localhost'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { die('?ould not connect: '. mysql_error()); } $db_selected = mysql_select_db(DB_NAME, $link); if (!$db_selected) { die('could not use ' . DB_NAME . ': ' . mysql_error()); } if($_POST['Submit']){ $value=$_POST['taskid']; $value2=$_POST['task']; $value3=$_POST['description']; $value4=$_POST['type']; $value5=$_POST['datedue']; $value6=$_POST['completed']; mysql_query("update tasks set taskid = '$value', task = '$value2', description = '$value3', type = '$value4', datedue = '$value5', completed = '$value6' WHERE taskid = 'taskid' "); header("location:viewalltasks.php"); exit; } $taskid=$_GET['taskid']; $result=mysql_query("SELECT * from tasks where taskid='$taskid'"); $row=mysql_fetch_assoc($result); mysql_close(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Update</title> </head> <body> <form id="form1" name="form1" method="post" action="<? echo $PHP_SELF; ?>"> <table width="600" border="1"> <tr> <td>Taskid</td> <td><?php echo $row['taskid']; ?></td> </tr> <tr> <td>Task</td> <td><input name="task" type="text" id="task" value="<? echo $row['task']; ?>"/></td> </tr> <tr> <td>Description</td> <td><textarea name="description" rows="5" id="description"><? echo $row['description']; ?></textarea></td> </tr> <tr> <td>Type</td> <td><input name="type" type="text" id="type" value="<? echo $row['type']; ?>"/></td> </tr> <tr> <td>Date</td> <td><input name="datedue" type="date" id="datedue" value="<? echo $row['datedue']; ?>"/></td> </tr> <tr> <td>Completed</td> <td><input <?php if (!(strcmp($row['completed'],"Yes"))) {echo "checked=\"checked\"";} ?> type="checkbox" name="checkbox" id="checkbox" /></td> </tr> <tr> <td> </td> <td><input type="Submit" name="Submit" value="Update" /></td> </tr> </table> </form> </body> </html> Thanks in advance
  9. I am still getting the 500 internal server error I have changed my php.ini however it is still only show the error above? Please see my code below. <?php define('DB_NAME', 'raggsweb_oltusers'); define('DB_USER', 'raggsweb_raggs'); define('DB_PASSWORD', 'XXXXX'); define('DB_HOST', 'localhost'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { die('çould not connect: '. mysql_error()); } include ('header.php'); include ('menu.php'); mysql_select_db(DB_NAME, $link); $result = mysql_query("SELECT * FROM procedures") or die(mysql_error()); <HTML> <BODY> echo "<table> <tr> <th scope='col'>Number</th> <th scope='col'>Procedure Name</th> <th scope='col'>Created By</th> <th scope='col'>View</th> <th scope='col'>Update</th> </tr>"; while($row = mysql_fetch_array($result)) { echo '<tr>'; echo '<td>'.$row['Procedure_number'].'</td>'; echo '<td>'.$row['Name'].'</td>'; echo '<td>'.$row['Created_by'].'</td>'; echo '<td><a href="/documents/'.$row['Uploadedfile'].'"><img src='/images/folder.png' width="25" height="25"></a></td>'; echo '<td> </td>' echo '</tr>'; } echo '</table>'; include ('footer.php'); </BODY> </HTML> ?> Can anyone help?
  10. Ok php is starting to annoy me. one tiny little key out and it stuff's everything up. I am getting a Server error Server is still up as other pages are working. <?php define('DB_NAME', 'raggsweb_oltusers'); define('DB_USER', 'raggsweb_raggs'); define('DB_PASSWORD', 'ctu158'); define('DB_HOST', 'localhost'); $link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { die('çould not connect: '. mysql_error()); } include ('header.php'); include ('menu.php'); mysql_select_db(DB_NAME, $link); $result = mysql_query("SELECT * FROM procedures") or die(mysql_error()); <HTML> <BODY> echo "<table> <tr> <th scope='col'>Number</th> <th scope='col'>Procedure Name</th> <th scope='col'>Created By</th> <th scope='col'>View</th> <th scope='col'>Update</th> </tr>"; while($row = mysql_fetch_array($result)) { echo '<tr>'; echo '<td>'.$row['Procedure_number'].'</td>'; echo '<td>'.$row['Name'].'</td>'; echo '<td>'.$row['Created_by'].'</td>'; echo '<td><a href=/documents/'.$row['Uploadedfile'].'><img src='/images/folder.png'></a></td>'; echo '<td> </td>' echo '</tr>'; } echo '</table>'; include ('footer.php'); </BODY> </HTML> ?> I think it has something to do with line 34 echo '<td><a href=/documents/'.$row['Uploadedfile'].'><img src='/images/folder.png'></a></td>'; it stuffed up when i changed it to. echo '<td><a href=/documents/'.$row['Uploadedfile'].'><img src='/images/folder.png' width="25" height="25"></a></td>'; When I removed "width="25" height="25"" and took it back to the original code it still did not work. What have I done Wrong? is there a principle that I am missing with PHP and Tables?
  11. You are a legend. Thank you for all your help.
  12. //This is the directory where images will be saved $target = "documents"; $targetx = $target . basename( $_FILES['Uploadfile']['Name']); Still getting the error the folder documents does exist. I have even copied and pasted it from the ftp "filezilla" to double check.
  13. Thanks DannyB, I am getting closer.I have a better error now. Data has saved in the database except the file location. File did not find it's way to the folder.
  14. Further Information. Fields Name, Procedure_number & Created_by are being now added to the database. however the link is not being added to the Uploadedfile field.
×
×
  • 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.