Jump to content

ronc0011

Members
  • Posts

    54
  • Joined

  • Last visited

ronc0011's Achievements

Member

Member (2/5)

0

Reputation

1

Community Answers

  1. I know this is a super newbie question but I am totally new to PHP and I’m coming from a Microsoft world i.e. ASP.NET also some early ActionScript. So today I’m hoping to find a good working explanation of these two operators.
  2. Really? Well clearly something's causing the errors that I apparently haven't spotted yet. As I've already noted I got the string entered just as you've given and it worked fine typed directly into the interface, While the attempt immediately before that I had done exactly the same thing only I had clicked on the next column definition and it threw the error. I suppose I may have typed a period "." instead of a comma "," somewhere though I was being pretty careful about that. As I noted before I had also by this time started trying to enter the list in shorter segments i.e. just 3 or 4 names, etc. I suppose I could try recreating different incorrect scenarios attempting to recreate the problem.
  3. Actually I tried that while wasting time waiting on totally useless & pointless responces from others. As it turned out I think it may have been a quirk in the way Workbench operates. I discovered that while I was entering the detail of a column such as an ENUM column, when I clicked to the next column to begine the next column expecting that Workbench would commit the entries I had just made. Instead it threw errors. It seems you absolutely must click the "Apply" button else if you click the next line where you would begin defining a new column Workbench chokes and throws an error saying that the data type you have given is not valid or something to that effect. Taking care to use the "Apply" button while also manually typing in the string does work. Oddly at one point I was typing in truncated versions of the string in question & still getting the error. Turns out it was the issue of moving to the next line in the Workbench interface that was causing the issue. This doesn't cause a problem if the data types are "VARCHAR(45)" or "INT" the default data type or INT. So actually I was just creating the columns like I had been doing all along but the ENUM() data type kept throwing this error for reasons I couldn't figure out. In the case of an ENUM() data type you must use the "Apply" button
  4. So you just aren't or can't answer the question why MySQL is giving me issues over my ENUM()data type. Lucky for me I managed to sort it out without any help from you. Or should I just accept the idea that for some weird inexplicable reason MySQL doesn't like my list of manufactures as an ENUM() data type.
  5. I really didn’t think the question was that difficult. When it’s all boiled down to its barest simplest element. The question is; “WHY is MySQL giving me errors on my ENUM() data type?”. Anyway, never mind that, I sorted it out, sort of. I really don’t have any questions about how I’m designing my tables. In fact, designing the table is what I’m doing. For you guys edification this is not a database for something like a dealership. It is intended to be a backend for a company’s fleet maintenance schedule. So of course the company might have Company cars, local & over the road delivery trucks, vans, etc. The Web based app needs to have an admin page where a manager can enter and update new records. At the same time the drivers, mechanics or other users need to be able to update individual maintenance records In any event the design part is what I’m actually doing now. In association with “make” & “model” there needs to be records for things like “oil change”, “Tire change”, “belts & hoses”, etc. then other things such as mileage per day – week, so on & so on… In this scenario “make” ideally needs to be a multiple choice drop down selection. So let’s move on from the separate table approaches. Granted as the design process moves forward no doubt many changes will need to be made as the need makes itself apparent.
  6. So that doesn't really answer the question does it? Design is still in it's early stages, nothings settled or even determined. At this point the only real question I have is what's up with the ENUM() data type. And BTW I just tried it with typing in the string by hand one at a time i.e building the string manually. It didn't like that either. I'm pretty sure I've done this before in PHPMyAdmin with less aggravation. In fact I created a column just before this one that worked just fine. However, it does occur to me that the previous column had no upper case characters in it but the "Model" column has and needs to use upper case characters in it i.e. GMC etc...
  7. I'm working with MySQL Workbench building a Database that will have multiple tables. and one of the columns needs to be an ENUM data type. And I don't seem to be able to provide the correct syntax or something. In the create table window I have selected the desired column "make' it's a cars DB and I want an ENUM type to list the various manufacturers i.e.; 'Ford’,‘GMC’,‘Chevorlet’,‘Chrysler’,‘Dodge’,‘Buick’,‘Toyota’,‘Volvo’,‘international’,‘Kenworth’,‘Peterbilt’,‘Mack’,‘Freightliner’,‘Isuzu’ For reasons I haven't been able to spot it keeps throwing this error. "The given Data Type contains errors" To avoid Type-O's I have been copy & pasting this string from a notepad file so I can double check my typing and syntax etc. Is it the copy & paste that's causing the issue?
  8. Actually the second one is just a leftover from me cutting and pasting. I copied the second one and pasted it into the space above the INSERT line and then I just forgot to comment out the first occurrence of it, the one at the bottom. It's just me shuffling stuff around and attempting to post the examples to this forum. Anyway your advice worked and pointed the way for me so now I can tweak to my hearts content and find and prove all my mistakes while knowing what's correct and works.
  9. OK just for clarity sake here is what just worked... <?php include 'conn.php'; if(isset($_POST ['fname'])) { $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $stmt = $db->prepare("INSERT INTO guest(fname, lname, email)VALUES(:fname, :lname, :email)"); $stmt->bindValue(':fname', $fname); $stmt->bindValue(':lname', $lname); $stmt->bindValue(':email', $email); $stmt->execute(); // I add this just to check that the asignment lines are working. echo "Hello" . $fname . " " . $lname . " " . "your email address is" . $email; } $stmt = $db->prepare("INSERT INTO guest(fname, lname, email)VALUES(:fname, :lname, :email)"); $stmt->bindValue(':fname', '$_POST["fname"]'); $stmt->bindValue(':lname', '$_POST["lname"]'); $stmt->bindValue(':email', '$_POST["email"]'); $stmt->execute(); /* if(isset($_POST ['fname'])) { $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; // I add this just to check that the asignment lines are working. echo "Hello" . $fname . " " . $lname . " " . "your email address is" . $email; } */ ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <form method="post" action="insert.php" > First Name: <input type="text" id="fname" name="fname" /><br /> Last Name: <input type="text" id="lname" name="lname" /><br /> email: <input type="text" id="email" name="email" /><br /> <input type="submit" value="submit" /> </form> </body> </html> I moved the INSERT statement inside the "if' statement and using the PHP variables " $fname, $lname, $email " this time without any quotes. I'm thinking that those two things together were what was giving me grief. I know you gave me references in the PHP documentation, I'll have to re-read back through this thread and track it down. Honestly the PHP documentation I find to be difficult to follow, thus my preference for the YouTube tutorials. I do in fact go to the PHP documentation periodically put it usually isn't my first choice 'Go To" resource. Well, I really do gotta go to work now. And thank you again for your help & patience.
  10. HA!!!! that did it I'm afraid the whole naming thing is really twisting me in knots. It's something I'm really going to have to work on a lot. I really gotta thank you a lot for your help & patience. I know I'm gonna be working a lot with this, ie. update, delete, select, etc. hopefully I'm on the right track now.
  11. One last attempt before I go to work. I did some more tinkering with the code and here's what I have now... <?php include 'conn.php'; if(isset($_POST ['fname'])) { $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; // I add this just to check that the asignment lines are working. echo "Hello" . $fname . " " . $lname . " " . "your email address is" . $email; } $stmt = $db->prepare("INSERT INTO guest(fname, lname, email)VALUES(:fname, :lname, :email)"); $stmt->bindValue(':fname', '$_POST["fname"]'); $stmt->bindValue(':lname', '$_POST["lname"]'); $stmt->bindValue(':email', '$_POST["email"]'); $stmt->execute(); /* if(isset($_POST ['fname'])) { $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; // I add this just to check that the asignment lines are working. echo "Hello" . $fname . " " . $lname . " " . "your email address is" . $email; } */ ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <form method="post" action="insert.php" > First Name: <input type="text" id="fname" name="fname" /><br /> Last Name: <input type="text" id="lname" name="lname" /><br /> email: <input type="text" id="email" name="email" /><br /> <input type="submit" value="submit" /> </form> </body> </html> OK so this isn't throwing errors. But what it is sending to the database is "$_POST["fname"], $_POST["lname"], $_POST["email"] " It seems no matter what I try to use in the bindValues lines i.e. $fname etc. or $POST_[fname]... no matter what it doesn't like it, period. Also the echo statement isn't doing anything.
  12. OK I'm back to working on this seemingly impossible tast. Here's what i'm trying to do. I have a prepared INSERT statement and I want to use values that I get from an html form. I can get the INSERT statement to work if it is the only thing on the page with no output back to the page but as soon as I start trying to incorporate the form retrieval elements or the output elements it all crashes... This works but it outputs nothing to the screen so I have to open PHPMyAdmin to check the results. but it is there ... <?php include 'conn.php'; $stmt = $db->prepare("INSERT INTO guest(fname, lname, email)VALUES(:fname, :lname, :email)"); $stmt->bindValue(':fname', 'alice'); $stmt->bindValue(':lname', 'may'); $stmt->bindValue(':email', 'a@may.me'); $stmt->execute(); ?> So OK when I try to feed this statement data from my form and then output it to the screen Nothing I try works which should be evident from the myriad post I've already made here on this subject. here's my latest attempt. <?php include 'conn.php'; /* if(isset($_POST ['fname'])) { $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; } */ $stmt = $db->prepare("INSERT INTO guest(fname, lname, email)VALUES(:fname, :lname, :email)"); $stmt->bindValue(':fname', '$_POST['fname']'); $stmt->bindValue(':lname', '$_POST['lname']'); $stmt->bindValue(':email', '$_POST['email']'); $stmt->execute(); if(isset($_POST ['fname'])) { $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; // I add this just to check that the asignment lines are working. echo "Hello" . $fname . " " . $lname . " " . "your email address is" . $email; } ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <form method="post" action="insert.php" > First Name: <input type="text" id="fname" name="fname" /><br /> Last Name: <input type="text" id="lname" name="lname" /><br /> email: <input type="text" id="email" name="email" /><br /> <input type="submit" value="submit" /> </form> </body> </html> NOTE: I have tried several variations on the values in the Bindvalues lines everything just keeps throwing errors. OK so I gotta go to work. Probably wont get back to this until tomorrow morning. Thank you to everyone who has been trying to help me with this.
  13. You were right I didn't see it at first. Like I said fatigue starts getting me. What I'm really trying to do is bind the values from my htmlform to the fname, lname, email placeholders, but when I started getting all these errors it derailed m. Got me totally off track of what I was trying to get to work.
  14. It's really starting to look like I'm in for a repeat of the same scenario I experienced sooo many times before. Tomorrow I'll have to go to work and I'll be exhausted when I get home and will never even think of this again until just maybe if nothing else cones up just maybe next weekend. Would'nt hold my breath. Just as likely to be another 6 months before I get to revisit this again. I do appreaciate you guys trying to help though. I think if I actually had a working example of code that does this complete from html form to the php that processes it and outputs the results to the page I could probably track down where I'm going astray
  15. benanamen, Well that is the point. I get lost in all this rewriting the code over and over between all the errors and everything else. Today is another example. Just like previous days fatigue is beginning to take hold and the never ending errors are really wearing me down. I’ve been at this going on 4 days and it keeps crashing around the same place I just rebuilt the example from a tutorial I was following and it works. It doesn’t output anything to the page but the new records do show up in the database. What this example doesn’t show is how to retrieve the values from an html form So what I’ve been attempting to do is combine the examples of processing form data with a prepared INSERT statement. I can get the prepared INSERT statement to work just fine… Current example. I just rebuilt this from the example I’m working from and it WORKS [code} <?php include 'conn.php'; echo "Hello World!"; $stmt = $db->prepare("INSERT INTO guest(fname, lname, email) VALUES (:fname, :lname, :email)"); $stmt->bindValue(':fname', 'manny'); $stmt->bindValue(':lname', 'danny'); $stmt->bindValue(':email', 'md@dann.com'); $stmt->execute(); ?> [/code] However the previous page same code persist in throwing this error. "Invalid parameter number: parameter was not defined in C:\Apache\htdocs\insert3\insert.php on line 9" BTW Line 9 is the execute line. Here is the previous page I was working with and when I couldn’t get it to stop throwing errors I cut it back to just the code from the tutorial example and it continues to throw the errors. It’s not a cash issue, I renamed it and it still errors So why is one page throwing errors and the other one isn’t? <?php include 'conn.php'; $stmt = $db->prepare("INSERT INTO guest(fname, lname, email)VALUES(:fname, :lname, :email)"); $stmt->bindValue(':firstname', 'johnny'); $stmt->bindValue(':lastname', 'bob'); $stmt->bindValue(':email', 'jb@coit.me'); $stmt->execute(); ?>
×
×
  • 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.