Jump to content

androidd

Members
  • Posts

    15
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

androidd's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. <?php while ($row = mysqli_fetch_assoc($com_sql)){ print "<tr>\n"; foreach ($row as $col=>$val){ print " <td>$val</td>\n"; } print "</tr>\n\n"; } ?> This is what worked. Found it in a book PhP5/MySQL Programming for Absolute Beginner (which I am ) XD Thanks for all the help everyone!
  2. * sorry correction this for connects to comic_info_db.comic_names then should be asking comic_db.comic_db what comics do you have that match Spider-Man or Spawn etc...
  3. yeah I guess I should explain better MySQL DB Info: ---------------------------------- |comic_info_db.comic_info | < ------------- This houses all the publishers and comic names (ex Marvel, Spider-Man) ---------------------------------- --------------------------- |comic_db.comic_db | <-------------- Houses all current comics in the collection (This is where I'm trying to get results from) --------------------------- PhP Pages ----------------- |Comic_form | <----| Comic_input | <---|---------------------------------This group takes info and inputs it into the comic_db.comic_db as I get more comics (Works) ------------------ --------------------- | Comic_Search | <------ (Problem Area) * Part of the form queries comic_info_db.comic_info to get the comic names | Comic_Results | <------- (Problem Area) Shows the search results that is queried from comic_db.comic_db ---------------------- So basically what should be happening is I go to store get new comic goto comic_form input all info about comic (Publisher, Comic Name, Comic Number, Misc Info etc..) then input the data into db and then time goes by I go into comic search and select from a drop down (That was populated from the db) and outputs all the comics it finds in the DB pertaining to what was selected in drop down. IE. drop down menu selects Superior Spider-Man and shows results. I don't want to type my values and possible mess up so I already added all the publishers and all the comic names into the db those values are what populate in the drop downs, I did this to make sure I didn't have to deal with Spider Man, Spider-Man, spider man, spider-Man, etc.... it would show only the data that was in DB and search for that data exactly as it exists in the DB. What I posted in the posts a couple before this shows a query to comic_info_db.comic_info to get the pub to make drop down then that form sends it to the OP form to process results. so it's a circular thing hope this helps explain the structure of what I'm trying to do... Sorry so long.
  4. mysqli_connect maybe? or something like: $db_connect = mysqli_connect($host, $user, $pass, $db); if (!$db_connect){ echo "Failed" . mysqli_error(); } Kinda new at this myself but this worked for me.
  5. For Ubuntu Server 12.04 during install process you have option to install mail server elements however seems that most add on Dovecot for Pop and Imap and then some other webmail if that is something you need. Also server doesn't come with a gui so if you needed one then you might want to find a stable copy of Debain or LTS version of Ubuntu Desktop(Not a huge fan of the new design but thats me) and then install your server elements (Apache, MySql, PHP, etc..) As far as tools since I run server and no gui seems that shell is my best friend / Geany on my Win box but it's easier to make change for me in the shell environment. webmin is handy if you need to administer the machine if you go the Ubuntu server route.
  6. should I be running the $_POST['comic_name'] through anything? Not sure if maybe when it asks the db for the info the search query passes the spaces and dashes as something else? I don't know how to ask this in google lol so I don't know if make sense sry.
  7. yeah it pulls the publishers out of comic_info_db.comic_info and then it posts the data into comic_db.comic_db - As I get new publishers I wanted to add into db and it auto populate my forms. - The search would pull the exact publisher data that has been inputted into the data base and then post into the main comic database and the query would ask that table what publishers or titles I currently own. I did it this way also so that when I ask the DB what info it has it will have as part of the search the exact string that is contained in the DB
  8. This is the page that queries the db for all the publishers in the collection then puts them in a drop down then submits to the form (OP coding) to query db to find all the rows for the desired publisher. // Query DB for Publisher Info // $query = "SELECT * FROM `comic_info_db`.`comic_name`"; $result = mysqli_query($comic_connect, $query); ?> <table height="10%"> <tr> <td> </td> </tr> </table> <p align="center"><img src="/images/comic_front.png" /></p> <form action="./comic_results.php" method="POST"> <table height=10% align="center"> <tr> <td> Comic Name: </td> <td> <select name="comic_name"> <option name="Null" value="--">--</option> <?php while($row = mysqli_fetch_array($result)) { echo "<option>" . $row['comic_name'] . "</option>\n"; } ?> </select> </td> <td><input name="submit" value="submit" type="submit" /></td> </tr> </table> </form>
  9. ahh the spaces I see my bad... after testing it out still didn't work. :/ I will keep at it. TY
  10. Thought that was what I had in most of those examples or a variant. Could you explain what you mean a lil more maybe I'm missing it. or show me with the code provided. Nope usually I call the scheme then the table just cause I have multiple tables I use so I figured it's easier to make a global connection to the DB then when I need something from the DB Tables I could jump from one to the other without the need to make different connections.. Hence the `comic_db`.`comic_db` <--- also this works when I call the DB comic names to fill out the form as well as the page that does the INSERT statement that inputs the comic variables. So while I see what your saying didn't help in this situation. TY though.
  11. Ok so more on my lil comic app... (and all was going so well) GOAL: Trying to take a value from a form and create sql statement to look for that comic title in the DB and show what has been entered. (I.E search for Spider-Man -> Shows all Rows that Pertain to Spider-Man) So I can't figure out what is wrong with my code. Soon as I enter in my while statement my php failes however my query seems to be doing just fine. I've used the same kind of template on other pages and it works just fine the only difference is when I added a WHERE statement to my sql query. * NOTE: If I take the output of my query and plug it into mysql workbench I get the correct tables and results so I'm yeah kinda confused. * NOTE: The way I retrieve the $data variable is from a query from the form page which pulls all the comic names from the DB and displays in a drop down so the values that it passes are the exact same names / titles from the DB itself. <?php require('./scripts/con_db.php'); // Query DB for Comic_Names // $data = $_POST['comic_name']; $query = "SELECT * FROM `comic_db`.`comic_db` WHERE `comic_name`='$data'"; $com_sql = mysqli_query($comic_connect, $query); if (!$com_sql){ echo "Failed to connect to db" . mysqli_errorno(); } ?> <body> <p align="center"><img src="./images/comic_front.png" /></p> <table align="center"> <tr> <?php while($row = mysqli_fetch_array($com_sql)) { echo "<td>" .$row "</td>"; } ?> </tr> </table> <br /> <br /> <?php require('./scripts/footer.php'); ?> I should also say i've tried these other passes as well with no luck : <?php while($row = mysqli_fetch_assoc($com_sql)) { echo "<td>" .$row "</td>"; } ?> while($row = mysqli_fetch_assoc($com_sql)) { echo "<td>" .$row['comic_name'] "</td>"; } ?> <?php while($row = mysqli_fetch_assoc($com_sql)) { echo "<td>" .$row['$data'] "</td>"; } ?> I've also tried something I found in a book that says to do extract($row) then do my echo "<td>" .$row "</td>"; but that didn't work either so I'm missing something here is what the output for the SELECT string gives me as well from the browser which seems to be fine and again if I plug into mysql workbench it displays what I need.. SELECT * FROM `comic_db`.`comic_db` WHERE `comic_name`='Iron Man - V5' TY for help guys I've try to keep the ??'s down but I'm missing something (probably pretty obvious) so I need some guidence.
  12. IT WORKED!!! XD soon as I swaped those around BAM data was entered. Thanks everyone for helping me with this.
  13. I've tried both right now It's set with ` instead of ' s around the column names but none of em seem to do it yet...
  14. Hey all this is my first time posting and was wondering if I could get some help and see what I am doing wrong. // I've tried my best to find my answer through google searches and after days of working on this I finally decided to ask for some guidence. // Project: I am trying to make a web based form that will take information about my comic books and input them into a mysql database. Info: I have got the code for the html input page all done and have it sending the $_POST[''] variables to another script that will actually input the data into the database. / In addition this app is only available to me and won't be facing the public world so I have left out the checks on the data since most of it is controled variables from the form. Problem: After I input the 7 values into the html form and submit them the script never inputs the data. I have echoed out the $_POST[''] variables to make sure they were being passed correctly and well they are. Question: It's a multi part question / a.) Can anyone see what I am doing wrong in my INSERT statement and mysqli_query b.) Is there a better way? I saw PDO but couldn't really wrap my head around it. c.) what could or should I be using to see what mysql is telling me when the INSERT statement runs to see if Its a problem on the other side. What I've done/tried: Seems like too much too say... lol but I've verified the user permissions for the DB and the user I'm connecting with and it has full rights on DB / Multiple INSERT statements but none of em work. / I've tried moving the table into a separate database scheme (still no go) / I've tried different ways of selecting the DB outside of the connection params as well as in the connection params with no favorable result. / I tried using the string that mysql workbench creates to input values the same as the php code to input values and that didn't work. Code: [comic_form.php] $comic_db = mysqli_connect("foo", "bar", "foobar", "comic_info_db"); if(!$comic_db){ echo "Connection to DB Failed"; } else { echo "Connect to DB Established"; } // Variables From Web Form $idcomic_db = $_POST['idcomic_db']; $publisher = $_POST['publisher']; $comic_name = $_POST['comic_name']; $comic_num = $_POST['comic_num']; $comic_cover = $_POST['comic_cover']; $price_paid = $_POST['price_paid']; $quantity = $_POST['quantity']; $sql_insert = "INSERT INTO `comic_db` (idcomic_db, publisher, comic_name, comic_num, comic_cover, price_paid, quantity) VALUES ('$idcomic_db', '$publisher', '$comic_name', '$comic_num', '$comic_cover', '$price_paid', '$quantity')"; $db_con = mysqli_query($sql_insert, $comic_db); $error = mysqli_error($db_con); In that same script I also have echoed the variables as well as the sql_insert string and this is what I get. I did this just to see what variables were being passed as well as the string that was being created. Dunno if there is a better way to do it. 1 Marvel Comics The Superior Spider-Man 1 original 3.99 1 INSERT INTO `comic_db`.`comic_db` (`idcomic_db`, `publisher`, `comic_name`, `comic_number`, `comic_cover`, `price_paid`, `quantity`) VALUES ('0', 'Marvel Comics', 'The Superior Spider-Man', '1', 'original', '3.99', '1') I've also included a screen shot of the table params from mysql. if it helps I also am using PHP Version 5.3.10-1ubuntu3.6 Sorry if this is lengthy thought more info would be better Thanks for the help
×
×
  • 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.