mikosiko
Members-
Posts
1,327 -
Joined
-
Last visited
-
Days Won
1
Everything posted by mikosiko
-
if your code is not showing errors means that you are not controlling them properly
- 1 reply
-
- mysql_query
- mysql
-
(and 3 more)
Tagged with:
-
also: http://dev.mysql.com/doc/refman/5.5/en/insert.html
-
if you are trying to not insert records with a duplicated "VIN", means then that you can define a UNIQUE index in that field (if it is not a PK already), and then you can simplify your logic using only an INSERT...IGNORE sentence and controlling/checking the outcome with mysqli_affected_rows()... something like this: (Abracadaver already told you to escape your $_POST[] before to use it directly in the query) $insert = "INSERT IGNORE INTO inventory (vin) VALUES ('$_POST[vin]')"; $result = mysqli_query($this->myconn, $insert); if ( !mysqli_affected_rows($this->myconn) ) { // Nothing was inserted... mysqli_affected_rows() return 0... means most likely a duplicated vin was found ... do whatever you want here } else { // the Insert was successful ... proceed.. } you can read here about INSERT...IGNORE format
-
with this line: if($rs19){ ..... you are testing if the Execute() method was indeed able to execute correctly the SQL sentence and return a valid recordset, however, as kicken pointed out before, that doesn't guarantee that the select effectively returned rows or not, and you are not checking/validating that condition. What you probably want to do is more or less this (only relevant code shown): $query19="select * from billing where `b_no`=$bno"; $rs19=$conn->execute($query19); if (!$rs19) { // validate that a valid recordset has been generated without errors or not print $conn->ErrorMsg(); exit(); // maybe you want to stop the script in case of error } else { // We have a valid record set (could be empty), one option is validate that it is not empty, other is loop the recordset WHILE it hasn't reached the EOF if ($rs19->EOF) { echo "No Records found... (or recordset exhausted)"; // do something else or exit } else { // Green light... rest of your code } } [EDIT]: this link could help : http://phplens.com/lens/adodb/docs-adodb.htm
-
using the $_POST[] values directly in your SQL's without sanitize them first let you totally open for SQL injections... sanitize them using the mysql_real_escape_string() should help http://php.net/manual/en/function.mysql-real-escape-string.php but as you will see in the linked manual mysql_ API is already deprecated, therefore the recommendation is to use the mysqli_ API or better PDO and prepared sql sentences. In addition to that, as Kicken posted, you have multiple rows with the same "cocode" meaning that you don't have an UNIQUE constraint on it or it is non defined as Primary Key, hence the multiples values
-
read carefully the "Description:" for the mysql_query() function. http://php.net/manual/en/function.mysql-query.php P.S.: Not related with your issue, but pay attention too to the big "Warning" at the beginning.
-
Yes... but remember that "=" is the assignment operator http://www.php.net/manual/en/language.operators.assignment.php no the comparison operator (== or ===) http://www.php.net/manual/en/language.operators.comparison.php BTW: mysql_ API is already deprecated, you should be using the mysqli_ or PDO Apis instead.
-
from the manual: " http://php.net/manual/en/function.mysql-query.php a syntactically correct UPDATE that doesn't affect any record doesn't return an error (FALSE), it only doesn't return a resultset. [EDIT] You posted a new code while I was replying to your first code... but same answer apply... not idea why now you included a SELECT only to check if the record was updated or not...
-
The code that you posted doesn't have ANY VISIBLE sql INSERT to store data in any table.... it has only UPDATES for one table based on the status.... without seen the code with the INSERTS help is not possible.
-
how that old say goes?..... "if everything looks right, then for sure you will find the issue between the keyboard and the chair"
-
You didn't post the full definition of your table...the one that start with CREATE TABLE.... etc..etc
-
post your full table definition and the complete results of this query: SELECT * (or at least "CustomerFirstName, CustomerLastName, ContactName and City") FROM Customers WHERE CustomerFirstName='Alfreds' AND CustomerLastName='Futterkiste'
-
in the line 43 of your first post where are you passing the parameter $ in_Condition to your update method?.. i don't see that your method manage in any way the missing parameter
-
You should start by normalizing your tables... the fact that you have "i1, i2, i3" in your user_items table means that it is not correctly designed and will bite you sooner or later... I better design could be: Items Table: (it is ok) id | Item | 1 | Cheese | 2 | Ham | 3 | Tomato | Users table ( the items that the user has doesn't belong here... hence table is normalized) id | user_name (?) 1 | freid001 Users_Items Table : (this must contain as many rows for a user as items he has) user_id | item_id| item_number 1 | 2 | 1 (user 1 has 1 of item# 2) 1 | 3 | 5 (user 1 has 5 of item# 3) now just make your select's JOINing the tables depending of your objectives
-
That is not necessarily true... according to the OP: is no warranty that the original query has the id's in sequence.. the WHERE and ORDER BY clauses (if present) can obviously affect the selected id's as well as their order.One possible solution is store in an array the selected id's in the order of the original query and use next () and prev () as needed.
-
from the manual " Return Values Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN queries mysqli_query() will return a mysqli_result object. For other successful queriesmysqli_query() will return TRUE." http://php.net/manual/en/mysqli.query.php
-
Just look the indicated tutorial in the website that I provided for you early... there are several examples of how to use the FPDF class
-
Help you with what?.... if you are looking for pre-made code for your objectives I doubt you can find something... the suggested libraries (classes) in my previous post are for you to explore/investigate/study pick the one that will help you to fulfill your objectives, and write your own code... in general, this forum objective is help you to solve issues with "your code" not to provide you full solutions... if you need a full solution you should then post in the freelance forum and probably paid for that. Check the tutotials in the FPDF website www.fpdf.org in particular the tutorial # 2 include a way to manage images
-
you should explore one of the many libraries available .... just search for "php image to pdf".... FPDF is one of them , Mpdf, dompdf to name a few... I have used fpfd before and it has good examples and the documentation is fair
-
so... we only know that you have some kind of scanned documents and you seems to want to merge them to produce an unique pdf file... - What type are your scanned documents?... pdf's, images, what?... if they are pdf's, merging them manually in an unique document is fairly simple using adobe or other tools. - Do you want to merge them automatically using php, based in some criteria to select the files to merge? I personally use a solution based on php and ghostscript (http://www.ghostscript.com) to merge multiple pdf's documents in an unique pdf file... fairly straight forward and simple to implement ... ghostscript came with several well documented examples.
-
where in the posted code are you displaying the content of the $display_block variable? ... I don't see it used in the code other than when it is defined/concatenated
-
finally!! good for you.... now... where we (all who helped) can redeem the free scuba lessons?...
-
is a little of lack of attention to the details on your part.... look what I wrote: $APPLICANT_TO_COMPLETE_FirstName = mysqli_real_escape_string($link, $_POST['APPLICANT_TO_COMPLETE_FirstName']); ..... $query = "INSERT INTO Driver_applicants (FirstName, LastName, Applicationdate, Phone, AltPhone, DL, StreetAddress, City, State, Zip) VALUES ('{$APPLICANT_TO_COMPLETE_FirstName}', <same for the other fields>...."; and now how you did translate that to your code (just one field show as example): $APPLICANT_TO_COMPLETE_FirstName = mysqli_real_escape_string($link, $_POST['APPLICANT_TO_COMPLETE_FirstName']); $result = mysqli_query($link, "INSERT INTO Driver_applicants (FirstName, LastName, Applicationdate, Phone, AltPhone, DL, StreetAddress, City, State, Zip) VALUES ('{APPLICANT_TO_COMPLETE_FirstName}, you see the difference? (other than the obvious that in my example I'm using the query string separated)... can you see it?
-
here you go... just one field as example: $APPLICANT_TO_COMPLETE_FirstName = mysqli_real_escape_string($link, $_POST['APPLICANT_TO_COMPLETE_FirstName']); ..... $query = "INSERT INTO Driver_applicants (FirstName, LastName, Applicationdate, Phone, AltPhone, DL, StreetAddress, City, State, Zip) VALUES ('{$APPLICANT_TO_COMPLETE_FirstName}', <same for the other fields>...."; $result = mysqli_query($link, $query); but, look kicken answer... it is the easiest/shortest one... just quoting part of his answer here in case you lost it:
-
lines 17 to 26 looks ok... but now you have to replace all the $_POST in the INSERT with the variables that you just created, other way is use mysqli_real_escape_string() directly in your INSERT sentence, it will eliminate the additional variables ... I will suggest you to look kicken answer too... he showed you another method using a function and how to use it in the INSERT.. either one that you use should put you in the right track