Jump to content

JpGemo

Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by JpGemo

  1. Very sorry, the only error in the code was $tablename=$_POST["tablename"]; where it should of been $tablename=$_POST["table"]; once that was corrected, the script worked, sorry, still getting used to error checking PHP
  2. the $tablename is in the submission '<select name = "table" id = "table" >'; $_POST["table"]; $tablename=$_POST["tablename"]; mysqli_query($con,"UPDATE $tablename SET $column='$colour'"); echo 'table', $_POST["table"]; and the final echo, echo's the result I submit from the first form. Sorry, I see my error in this code
  3. This code is to change the result in one of my tables but the result won't change This is the form to submit the values to the processing page <?php //connect include 'connect.php'; //head include 'head.php'; //colour table $form = $_POST['selform']; $sql = "SHOW TABLES FROM $db_name"; $result = mysqli_query($con,$sql); echo '<form id="form1" name="form1" method="post" action="/BYO/modifyproc.php">'; echo '<table width="75%" border="0">'; echo '<tr>'; echo '<td>Table</td>'; echo '<td>'; echo '<select name = "table" id = "table" >'; //list tables while ($row = mysqli_fetch_array($result)) { echo '<option>'.$row[0].'</option>'; } //formtable 2 echo '</select>'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td>Column</td>'; echo '<td><input name="column" type="text" id="column" size="50" value=""/></td>'; echo '</tr>'; echo '<tr>'; echo '<td>Result</td>'; echo '<td><input name="colour" type="text" id="colour" size="50" value=""/></td>'; echo '</tr>'; echo '<tr>'; echo '<td> </td>'; echo '<td><input type="submit" name="Submit" value="Register"/></td>'; echo '</tr>'; echo '</table>'; echo '</form>'; ?> This page receives the form data and update the table <?php //connect include 'connect.php'; //head include 'head.php'; //recieve posts $_POST["table"]; $_POST["column"]; $_POST["colour"]; //convert posts $tablename=$_POST["tablename"]; $column=$_POST["column"]; $colour=$_POST["colour"]; //add to table mysqli_query($con,"UPDATE $tablename SET $column='$colour'"); echo 'table', $_POST["table"]; echo 'column', $_POST["column"]; echo 'result', $_POST["colour"]; ?> All of the results echo to the page, and the page source doesn't show any incorrect values, but the table isn't updating with the new value Any suggestions would be great
  4. Yer, mac, I worked out the {} part in the code, after changing my result code back to what was suggested at the start of the forum, and those changes fixed it (and yer, value1 and value2 is what I set the columns to for the purpose of getting my script right) but the script is working completely the way I was aiming for it to work, so thanks everyone
  5. That worked Ch0cu3r Thank You everyone, the code is working exactly the way I wanted it to now, Sorry for being so much of a Noob, I have spotty internet here, and noone I know, knows anything to do with web design, so I have to teach myself everything, so I often have to spend hours on my codes getting to work correctly, but I likely never wouldve worked this one out without everyones help. Thanks against
  6. This is how the script looks now, this is the form script <?php //connect include 'connect.php'; //head include 'head.php'; //list table process $form = $_POST['selform']; $sql = "SHOW TABLES FROM $db_name"; $result = mysqli_query($con,$sql); //formtable echo '<form id="form1" name="form1" method="post" action="/BYO/formprocessing.php"> <table> <tr> <td><select name = "selform" id = "selform">'; //list tables while ($row = mysqli_fetch_array($result)) { echo '<option>'.$row[0].'</option>'; } //formtable 2 echo '</select>'; echo '</td> </tr> <tr> <td><input type="submit" name="Submit" value="Register"/> </td> </tr> </table>'; ?> this is the processing script <?php //connect include 'connect.php'; //head include 'head.php'; //processing $table = $_POST["selform"]; $sql = 'SELECT * FROM '.$table ; echo $sql; $result = mysqli_query($con,$sql); if(!$result) echo("Error result: " . mysqli_error($con)); exit; while ($row = mysqli_fetch_array($result)) echo $row['value1']; echo $row['value2']; ?> the error message has disappeared now, however the table data isn't being echo'd either
  7. alright, I changed my option tags and that has removed the </br> tags from the posting form, but the </br> is there in the processing script, how can I remove that then EDIT: The </br> isn't appearing, however the data from the tables isn't appearing either
  8. well when I echo the $_POST['selform'] from the processing page, it echo's the value I submitted from the form, regardless which option I choose it echo's the result I intend it to, so it should be how I have written the option code
  9. This is the form, that is posting the value (head) as you can see, the value (head) is being retrieved from the database and then posted to the processing script <?php //connect include 'connect.php'; //head include 'head.php'; //list table process $form = $_POST['selform']; $sql = "SHOW TABLES FROM $db_name"; $result = mysqli_query($con,$sql); //formtable echo '<form id="form1" name="form1" method="post" action="/BYO/formprocessing.php"> <table> <tr> <td><select name = "selform" id = "selform">'; //list tables while ($row = mysqli_fetch_array($result)) { echo '("<option value="'; echo ($row[0]),'</br>'; echo '</br>">'; echo ($row[0]),'</br>'; echo '</option>")'; } //formtable 2 echo '</select>'; echo '</td> </tr> <tr> <td><input type="submit" name="Submit" value="Register"/> </td> </tr> </table>'; ?> This next script should then take the value submitted from the form, in this case (Head) then use it to display ALL the information that is contained inside that table <?php //connect include 'connect.php'; //head include 'head.php'; //processing $table = $_POST["selform"]; $result = mysqli_query($con,"SELECT * FROM `$table`"); if(!$result) echo("Error result: " . mysqli_error($con)); exit; while ($row = mysqli_fetch_array($result)) echo $row['value1']; echo $row['value2']; ?>
  10. if it didnt exist, then it couldn't be submitted, the table name head is being pulled from the database
  11. Ok, look ill explain it in more detail. I have 1 page, that has a form, that form allows you to pick an option from a drop down menu, the drop down menu is a list of the TABLE names, so when you hit SUBMIT, it is submitting a table name that is retrieved from the database. In the error report, the word (Head) was pulled from the database to be submitted. So the script is connecting to the database and retrieving the table name, but when I hit submit, the table name it is searching for is Databasename.Tablename, which in the error report looks like ****.head (btw, the report is displaying the ACTUAL database name, not **** , I just don't share information regarding my database connection)
  12. The connection is fine, I am getting the (head) value from the database, and submitting it to this script, unfortunately the script isn't echoing the values within the table, because it is adding the database name to the table name, so it is searching for the wrong table
  13. I am aware of that, the connection works fine, if you read the whole script and the results I have posted, I have received values returned from the scripts which require the connection to the database to be working. So it is not a connection to the database thats the issue
  14. I dont share information regarding the connection to my server. the error appears as Error result: Table 'Databasename.head' doesn't exist This is how the code looks now, <?php //connect include 'connect.php'; //head include 'head.php'; //processing $table = $_POST["selform"]; $result = mysqli_query($con,"SELECT * FROM `$table`"); if(!$result) echo("Error result: " . mysqli_error($con)); exit; while ($row = mysqli_fetch_array($result)) echo $row['value1']; echo $row['value2']; ?> The original suggested change to my result script had no change to the error result, until I changed my result script back and added the last change to $table, making it `$table`
  15. Ok, that has gotten alot closer, however it's now coming up with an error, where it is bringing forward the Database name also. searching for a table named, "DatabaseName.TableName"
  16. Error result: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 This is the error brought forward
  17. atm, sanitizing the script isn't the issue for me, its getting the script to generate the result. This part of the script generates the result I need; $sql = 'SELECT * FROM '.$table ; echo $sql.'<br>'; $result = mysqli_query($con,$sql); however, it is coming up with an error while bringing the result from that script to displaying the result, is there an alternative to the following script while ($row = mysqli_fetch_array($result)) echo $row['value1']; echo $row['value2'];
  18. Ok, I so im getting the error on the; while ($row = mysqli_fetch_array($result)) echo $row['value1']; echo $row['value2']; The echo $sql has brought the body value forward which is what I was after, so something is going wrong in this part of the code
  19. im just teaching myself PHP atm, so im testing possible methods of creating an administration panel for my websites That change still presented with the same error i've been getting mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in <b>/misc/29/516/897/696/user/web/gemoweb.com/BYO/formprocessing.php I only get this error while using a key in the query instead of typing the actual word
  20. <?php //connect include 'connect.php'; //head include 'head.php'; //processing $table = $_POST['selform']; $result = mysqli_query($con,'SELECT * FROM '.$table.''); while ($row = mysqli_fetch_array($result)) echo $row['value1']; echo $row['value2']; ?> I have changed "$result = mysqli_query($con,'SELECT * FROM '.$table.'');" to "$result = mysqli_query($con,'SELECT * FROM body'); (body) is the value of the post, and the script runs correctly using the work, but how can I get the value of $table to work in the script, I have also tried using $_POST['selform'] instead of $table, however that didn't work either?? Any suggestions would be great, thank you
×
×
  • 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.