Jump to content
Larry Ullman's Book Forums

Dark Prince

Members
  • Posts

    62
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Dark Prince

  1. Yes and Yes you did understand right while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee'); echo '<tr bgcolor="' . $bg . '"> I ran the query manually in mysql and it shows the first results, but when viewed in a browser in html table format the first result is not returned only the ones following after.
  2. in a while loop the first query row is not shown only the ones following after , the loop is an html table
  3. well in some of my tables there is more then 1 file upload per row, but yeah it was crc32 and yeah you are right I should just check it myself to see what I get.
  4. I just found it odd looking at it in a literal way because it's checking to see if mysql has an affected row then to run it again the affected row would have already been affected, unlike mysqli_num_rows where you have to also include the query and not just the database connection
  5. with the mysqli_affected_rows() function can it be run more then once in a script that has more then 1 update or insert query? like eg. I have an update query in a script and after the query is run I use if (mysqli_affected_rows($dbc) == 1) { // if this table is updated only then update the other table. $query2 = "UPDATE etc. etc." $result2 = mysqli_query($dbc, $query2); // Can I use mysqli_affected_rows() again here? } else { // First update did not work. // echo error statement here. }
  6. I'm not sure I want to use it for identify rows in a table yet but it would be nice to be able to add a 8 character hash to some fields like file uploads having a hash before the file name will reduce the likeliness of a file being overwritten by 99.999%, does cr32 create an 8 character hash or does it need to be truncated?
  7. I just want to create a short 8 to 12 character hash code that I can use to identify certain rows in a table instead of using an id number, and also to be used in a security check.
  8. you want to give attackers a hard time add 2 fields to your user table make one a char or varchar of 32 for md5 and a timestamp then when they login do an update query that adds the server time and an md5 hash then create a function in the page that checks the sessions md5 and timestamp against what was in the database that way even if they can guess the session name they can't guess the time the user logged in and a 32 xharacter hash
  9. yeah it was the quotes but also the TABLE part after UPDATE would still stall the query, and the ones without values are NULL set by the php code if the field is empty. I thought it was missing quotes but I didn't give it thought because of your first example and thought something else was messing it up like maybe I got a column wrong and put an alpha numeric value in a numeric only field. but everything is working now thanks alot guys for your patience
  10. tried that too i even put UPDATE tablename WHERE column=value SET , instead of the WHERE at the end of the query I even tried adding the IGNORE as well.
  11. phpmyadmin gives error 1064 I don't get it all the information being updated was just entered into an insert query with the other 2 columns not used in the update query the datetime and a counter field and it works just fine, but when its run in an update query it keeps stopping at the sql syntax error.
  12. those aren't the actual name of the column's I edited them to keep it down to just the code itself without given names and variables. so here is an edited version of the query being run. 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 'TABLE tablename SET column2=random field, column3=1, column4=87517, column5=1, column6=sell, ' at line 1 Query: UPDATE TABLE tablename SET column2=random field, column3=1, column4=87517, column5=1, column6=sell, column7=big description field is boring to fill out., column8=key field who cares, column9=nother key field jeeze, column10=random unneeded field, column11=boring blah blah, column12=, column13=, column14=, column15=, column16=, column17= WHERE column1=14
  13. there are so many generators for hash codes whats the best one to generate low character hashes around 6 to 12 characters?
  14. its running the exact one in my post up above. this is my table structure if this might have something to do with it. Field------------type------------------null-key------default-------extra----------- column1---int(10)unsigned---------no--pri---------null----auto_increment column2---varchar(60)--------------no--mul--------null------ column3---int(10)--------------------no--mul--------null------ column4---int(10)--------------------no---------------null------ column5---varchar(60)-------------no--mul---------null------ column6---varchar(5)---------------no---------------null------ column7---text-----------------------no----------------null------ column8---varchar(60)-------------no--mul---------null------ column9---varchar(60)-------------no--mul---------null------ column10--varchar(60)------------no--mul---------null------ column11--varchar(30)------------no----------------null------ column12--text----------------------no----------------null------ column13--text----------------------no----------------null------ column14--text----------------------no----------------null------ column15--text----------------------no----------------null------ column16--text----------------------no----------------null------ column17--text----------------------no----------------null------ column18--timestamp--------------no--------current_timestamp---on update current_timestamp column19--int(11)------------------no----------------null------ with this legend the query being run is this if (empty($errors)) { $queryud = "UPDATE TABLE table SET column2=$value2, column3=$value3, column4=$value4, column5=$value5, column6=$value6, column7=$value7, column8=$value8, column9=$value9, column10=$value10, column11=$value11, column12=$value12, column13=$value13, column14=$value14, column15=$value15, column16=$value16, column17=$value17 WHERE column1=$id"; $resultud = mysqli_query($dbc, $queryud); if (mysqli_affected_rows ($dbc) == 1) { header("Location: $cpage"); //changes have been saved auto-refresh. /* mysqli_close($dbc);*/ } else { echo '<p>Your changes could not be saved.</p>'; echo '<p>' . mysqli_error($dbc) . '<br/><br/>Query: ' . $queryud . '</p>'; } } else { // if $errors is not empty echo '<h1>ERROR!</h1> <p class="error">You forgot the following:<br/>'; foreach ($errors as $msg) { echo " - $msg<br/>\n"; }
  15. I get 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 'TABLE tablename SET column1=value1, column2=value2, column3=value3, column4=value4, column5=value' at line 1 the error cuts out the last letter of the 5th value soi checked out everyrhing to do with values setting in post checking and the html form to the trimming and it is normal so I am really stumped here
  16. to add to antonio's reply if (mysqli_affected_rows($stmt4) => 1)) // if there is 1 or more records affected it will return true. { // what to do here } if you want to check if there is no affected rows just change to == 0
  17. $ph = (isset($_FILES['photo']['name'])); was his error, $ph = $_FILES['photo']['name']; was the fix, am I right?
  18. $id = $_GET['id']; if ($value1 && $value2 && $value3 && $value4 && $value5 && $value6 && $value7 && $value8) { // These are needed fields $queryud = "UPDATE TABLE table SET column1=$value1, column2=$value2, column3=$value3, column4=$value4, column5=$value5, column6=$value6, column7=$value7, column8=$value8, column9=$value9, column10=$value10, column11=$value11, column12=$value12, column13=$value13, column14=$value14, column15=$value15, column16=$value16 WHERE id=$id"; $resultud = mysqli_query($dbc, $queryud); } else { echo '<p>You left a key field empty.</p>'; } if (mysqli_affected_rows ($dbc) == 1) { echo '<p>Your changes have been saved.</p>'; mysqli_close($dbc); } else { echo '<p>Your changes could not be saved.</p>'; }
  19. Ok I'm still having a problem my query isn't updating any information at all but it is not giving any errors other then my set error on a failed affected row check , in the start of my code it gets all the information from a SELECT query and then fills it into the html fields after all the php code, so there is a connection with the database, but if I change anything inside the fields and hit the submit which initiates all the field checks then passes into the UPDATE query then reloads the page but none of the fields change from the original information?
  20. this is a weird error as because it was working fine before then all of the sudden I get this syntax error, unexpected ',' on the line it describes it doesn't make sense the , should be there. if($value1, $value2, $value3) { thats where it is giving the error makes no sense...
  21. thank you larry i get confused where too look in the books i have your 2nd,3rd edition php and mysql and 2nd edition adv php
  22. I had just realized now that in my thread i had started previous to this i asked how to update multiple rows in a table what i actually meant was columns in a row i need to use the UPDATE function in a mysqli query to update most of the columns in a row i used UPDATE column1, column2, etc... SET VALUES ('$value1', '$value2', etc...) i thought this was the correct syntax but it is not updating any columns at all.
×
×
  • Create New...