Jump to content

jakebur01

Members
  • Posts

    885
  • Joined

  • Last visited

Everything posted by jakebur01

  1. query failed: insert into order_items values ('243', '753-04376', 223.99, 1)Could not store data, please try again.
  2. PHP Parse error: syntax error, unexpected ')', expecting ',' or ';' in
  3. I am having trouble finding out where my problem is. One of these queries is returning false. How do I find out which one it is? function insert_order($order_details) { // extract order_details out as variables extract($order_details); // set shipping address same as address if(!$ship_name&&!$ship_address&&!$ship_city&&!$ship_state&&!$ship_zip&&!$ship_country) { $ship_name = $name; $ship_address = $address; $ship_city = $city; $ship_state = $state; $ship_zip = $zip; $ship_country = $country; } $conn = db_connect(); // insert customer address $query = "select customerid from customers where name = '$name' and address = '$address' and city = '$city' and state = '$state' and zip = '$zip' and country = '$country'"; $result = $conn->query($query); if($result->num_rows>0) { $customer = $result->fetch_object(); $customerid = $customer->customerid; } else { $query = "insert into customers values ('0', '$name','$address','$city','$state','$zip','$country')"; $result = $conn->query($query); if (!$result) return false; } $customerid = $conn->insert_id; $date = date('Y-m-d'); $query = "insert into orders values ('0', $customerid, ".$_SESSION['total_price'].", '$date', 'PARTIAL', '$ship_name', '$ship_address','$ship_city','$ship_state','$ship_zip', '$ship_country', '0', '0', '0', '0', '0', '0', '0','0','0','0','0','0','0','0')"; $result = $conn->query($query); if (!$result) return false; $query = "select orderid from orders where customerid = $customerid and amount > ".$_SESSION['total_price']."-.001 and amount < ".$_SESSION['total_price']."+.001 and date = '$date' and order_status = 'PARTIAL' and ship_name = '$ship_name' and ship_address = '$ship_address' and ship_city = '$ship_city' and ship_state = '$ship_state' and ship_zip = '$ship_zip' and ship_country = '$ship_country'"; $result = $conn->query($query); if($result->num_rows>0) { $order = $result->fetch_object(); $orderid = $order->orderid; } else return false; $_SESSION['ordernumber'] = $orderid; // insert each book foreach($_SESSION['cart'] as $isbn => $quantity) { $detail = get_book_details($isbn); $query = "delete from order_items where orderid = '$orderid' and isbn = '$isbn'"; $result = $conn->query($query); $query = "insert into order_items values ('$orderid', '$isbn', ".$detail['price'].", $quantity)"; $result = $conn->query($query); if(!$result) return false; } return $orderid; }
  4. Thanks guys! I did some renaming and also moved around my table tags. It works great now! `Jake $result = mysql_query("SELECT * FROM dog_listing WHERE `Breed` = '$breed' ORDER BY Date_created ASC ", $db) or die(mysql_error()); echo "<h3>$breed".' '."Puppies</h3>"; echo "<table cellpadding=2 cellspacing=3>"; while($myrow = mysql_fetch_array ($result)) { echo "<tr><td>"; $Link=$myrow['Link']; if($myrow['Link']==0) { echo "<img src=\"images/puppy_holder.jpg\">"; } else { echo "<img src=\"$Link\">"; } echo "</td><td>"; $Breed_id=$myrow['Breed_id']; $Breed=$myrow['Breed']; $Username=$myrow['Username']; $Zip=$myrow['Zip']; $Date_expired=$myrow['Date_expired']; $Expiration=$myrow['Expiration']; $Date_created=$myrow['Date_created']; $Type=$myrow['Type']; $Champion_bloodline=$myrow['Champion_bloodline']; $Champion_sired=$myrow['Champion_sired']; $Price=$myrow['Price']; $Shipping=$myrow['Shipping']; $Description=$myrow['Description']; $Birthdate=$myrow['Birthdate']; $result1 = mysql_query("SELECT Company, City, State, Phone FROM dog_account WHERE `username` = '$Username' ", $db) or die(mysql_error()); while($myrow1 = mysql_fetch_array ($result1)) { $Company=$myrow1['Company']; $City=$myrow1['City']; $State=$myrow1['State']; $Phone=$myrow1['Phone']; } echo "<small><b>$Company</b> - $Date_created</small><hr />"; echo "<b>Type:</b> $Type<br />"; echo "<b>Description:</b> $Description<br />"; echo "<b>Price:</b> $Price<br />"; echo "<b>Birthdate:</b> $Birthdate<br />"; echo "<b>Shipping:</b> $Shipping<br />"; echo "<b>Champion Bloodline?</b> $Champion_bloodline<br />"; echo "<b>Champion Sired?</b> $Champion_sired<br />"; echo "$City, $State | $Phone"; echo "</td></tr><tr><td> </td></tr>"; } echo"</table>"; ?>
  5. This is only returning one row for some reason. It is supposed to be pulling and displaying two rows. Thanks, Jake $result = mysql_query("SELECT * FROM dog_listing WHERE `Breed` = '$breed' ORDER BY Date_created ASC ", $db) or die(mysql_error()); echo "<h3>$breed".' '."Puppies</h3>"; echo "<table cellpadding=2 cellspacing=3><tr><td>"; while($myrow = mysql_fetch_array ($result)) { $Link=$myrow['Link']; if($myrow['Link']==0) { echo "<img src=\"images/puppy_holder.jpg\">"; } else { echo "<img src=\"$Link\">"; } echo "</td><td>"; $Breed_id=$myrow['Breed_id']; $Breed=$myrow['Breed']; $Username=$myrow['Username']; $Zip=$myrow['Zip']; $Date_expired=$myrow['Date_expired']; $Expiration=$myrow['Expiration']; $Date_created=$myrow['Date_created']; $Type=$myrow['Type']; $Champion_bloodline=$myrow['Champion_bloodline']; $Champion_sired=$myrow['Champion_sired']; $Price=$myrow['Price']; $Shipping=$myrow['Shipping']; $Description=$myrow['Description']; $Birthdate=$myrow['Birthdate']; $result = mysql_query("SELECT Company, City, State, Phone FROM dog_account WHERE `username` = '$Username' ", $db) or die(mysql_error()); while($myrow = mysql_fetch_array ($result)) { $Company=$myrow['Company']; $City=$myrow['City']; $State=$myrow['State']; $Phone=$myrow['Phone']; } echo "<small><b>$Company</b> - $Date_created</small><hr />"; echo "<b>Type:</b> $Type<br />"; echo "<b>Description:</b> $Description<br />"; echo "<b>Price:</b> $Price<br />"; echo "<b>Birthdate:</b> $Birthdate<br />"; echo "<b>Shipping:</b> $Shipping<br />"; echo "<b>Champion Bloodline?</b> $Champion_bloodline<br />"; echo "<b>Champion Sired?</b> $Champion_sired<br />"; echo "$City, $State | $Phone"; echo "</td></tr>"; } echo"</table>"; ?>
  6. WOW!!! THank you so much. I really appreciate you helping me. It works great now!
  7. Thank you for taking the time to help me. It's working now, but it's only listing two rows. And their are a couple of hundred categories. <?php @ $db = mysqli_connect(''); $sql = "SELECT count(dog_listing.Breed_id) AS list_count, dog_breed.Breed_id AS Breed_id, dog_breed.Breed AS Breed FROM dog_breed LEFT JOIN dog_listing ON dog_breed.Breed_id = dog_listing.Breed_id WHERE dog_breed.Breed_id <= '93' GROUP BY dog_listing.Breed_id ORDER BY dog_breed.Breed_id ASC"; $result = mysqli_query($db, $sql) or die("There is an error in your query ".mysqli_error($db)); while($rows = mysqli_fetch_assoc($result)){ echo $rows['Breed']." has ".$rows['list_count']." Listings<br>\n"; } ?> //printed this on page //Please Select A Breed Below. //Affenpinscher has 1 Listings //Afghan Hound has 0 Listings
  8. There is an error in your query PHP Warning: mysqli_query() expects parameter 2 to be string, object given in C:\Inetpub\Websites\TWOPOINTENTERPR\JHearnsberger\index.php on line 236
  9. ok, I believe I corrected the linking. But, not all of the categories are in the dog_listing table...is this what this error is about. That it is not returning any rows? There is an error in your query PHP Warning: mysqli_query() expects parameter 2 to be string, object given in C:\Inetpub\Websites\index.php on line 236 PHP Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\Inetpub\Websites\index.php on line 236 $sql=mysqli_query($db, "SELECT count(dog_listing.Breed_id) AS list_count, dog_breed.Breed_id AS Breed_id, dog_breed.Breed AS Breed FROM dog_listing AS dog_listing LEFT JOIN dog_breed AS dog_breed ON dog_breed.Breed_id = dog_listing.Breed_id WHERE dog_breed.Breed_id <= '93' GROUP BY dog_listing.Breed_id ORDER BY dog_breed.Breed_id ASC"); $result = mysqli_query($db, $sql) or die("There is an error in your query ".mysqli_error()); while($rows = mysqli_fetch_assoc($result)){ echo $rows['Breed']." has ".$rows['list_count']." Listings<br>\n"; } `Jake
  10. thanks Ray, but now i am getting this error: PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result $result=mysqli_query($db, "SELECT count(dog_listing.Breed_id) AS list_count, dog_breed.Breed_id AS Breed_id, dog_breed.Breed AS Breed FROM dog_breed AS dog_breed LEFT JOIN dog_breed AS dog_breed ON dog_breed.Breed_id = dog_listing.Breed_id WHERE dog_breed.Breed_id <= '93' GROUP BY dog_listing.Breed_id ORDER BY dog_breed.Breed_id ASC"); while($rows = mysqli_fetch_assoc($result)){ echo $rows['Breed']." has ".$rows['list_count']." Listings<br>\n"; } `Jake
  11. what would i put after that statement to display the # of rows?
  12. i have two tables, one for categories and one for actual listings. I am trying to list the number of listings avail able in the category by counting the number of listings in the dog_listing table and displaying it next to each category. My problem is that I am getting the first category being repeated all the way down the page until it times out. It is not looping through each category in the dog_breed table for some reason. if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $limit=30; // rows to return $numresults=mysqli_query($db, "SELECT * FROM dog_breed"); $numrows=@mysqli_num_rows($numresults); // next determine if offset has been passed to script, if not use 0 if (empty($offset)) { $offset=1; } $result=mysqli_query($db, "SELECT Breed_id, Breed from dog_breed where `Breed_id` <= '93' order by Breed_id asc ");//. echo "<table><tr><td><div style=padding-left:25px; padding-top:5px>"; while ($myrow=mysqli_fetch_array($result)) { $id = stripslashes($myrow["Breed_id"]); $breed = stripslashes($myrow["Breed"]); if($result = mysqli_query($db,'select * from dog_listing ' ."where Breed_id='$id' " ." and Breed='$breed'")) { $row_cnt = mysqli_num_rows($result); } else { $row_cnt = 0; } echo "<strong><a href=\"#\">$breed ($row_cnt)</a><strong><br />"; }
  13. no errors returned, the first 2 querys deleting, creating, and copying the table is not executing - the one before dataloadinfile and dataloadinfile themselves are executing
  14. I am having trouble getting my table to drop and then create a new table based on another. $connect = mysql_connect($db_host,$db_user,$db_pass); mysql_select_db($db_name)or die("Couldn't select"); // Empty table $query = "DROP TABLE IF EXISTS `jhearnsberger.books_copy`"; mysql_query($query); $query = "CREATE TABLE IF NOT EXISTS `jhearnsberger.books_copy` SELECT * FROM `jhearnsberger.books`"; mysql_query($query); $query = "DELETE FROM $db_name.$destable"; $result = mysql_query($query)or die("Couldn't delete"); // do the data import $query = "load data infile \"$source_file\" INTO TABLE $destable FIELDS TERMINATED BY '|'"; $result = mysql_db_query($db_name, $query, $connect) or die(mysql_error());
  15. I have 22,507 rows that are being pulled from my TBP category. I would like to create three different php pages and have each one display only a third of the 22,507. Ex. page 1 would pull the first 1 - 7,502 page 2 would pull 7,503 - 15,004 page 3 would pull 15,005 - 22,507 What would be the best way to code this?
  16. i removed the whitespace from the code, what are you referring to?
  17. for some reason I wind up with a big white gap and have to scroll down to see my results. $db = mysql_connect('') or die(mysql_error()); mysql_select_db('') or die(mysql_error()); $result = mysql_query("SELECT * FROM wedding ORDER BY Dealer ASC ", $db) or die(mysql_error()); echo "<TABLE width=250 BORDER=1>"; while($myrow = mysql_fetch_array ($result)) { echo "<tr>"; echo "<td width=10><a href=\"edit_dealer.php?id=".$myrow[id]."\">Edit</a> <hr /> <a href=\"delete_dealer.php?id=".$myrow[id]."\">Delete</a></td>"; echo "<td>"; echo "<b>{$myrow['Dealer']}, {$myrow['Name']}</b><br />{$myrow['Address']}<br />{$myrow['City']} {$myrow['State']} {$myrow['Zip']} <br /> {$myrow['Phone']}<br />"; echo "</td></tr><br />"; } echo "</table>";
  18. how would i do something like: if (expiration date is less than date("Y-m-d")) { echo your account has expired; } else { carry on }
  19. I want to use the date(Y-M-D) function to store a modified date and an expiration date. How could I create an expiration date based on todays date. Example. todays date + 12 months = expiration. Also how could I display how many days it is until the expiration date?
  20. thanks, should i use single or double quotes with $_POST?
  21. i am posting the following data , should i add trim() around them and add backslashes? they are being posted to the page where i am checking all the fields before storing the data. $username = $_POST["username"]; $email = $_POST["email"]; $pass1 = $_POST["pass1"]; $pass2 = $_POST["pass2"]; $secure = $_POST["secure"]; $agree = $_POST["agree"];
  22. thank you , ken
  23. if i put my connection on the page, is their a possibility that ppl can see it? if so, how? why do most ppl use include files?
  24. I am needing to check to see if a username is already in use or not. I want to query my mysql database customer table to see. Fields id, user, pass, email. What would the query and loop look like?
  25. what could have changed on the server that would have suddenly caused the error: "PHP Warning: mysqli_error() expects exactly 1 parameter, 0 given" in the above code?
×
×
  • 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.