Jump to content

SauloA

Members
  • Posts

    54
  • Joined

  • Last visited

    Never

About SauloA

  • Birthday 12/27/1985

Contact Methods

  • Website URL
    http://www.otakuwanted.com

Profile Information

  • Gender
    Male
  • Location
    California

SauloA's Achievements

Member

Member (2/5)

0

Reputation

  1. When submitting the form, the records are sometimes inserted and sometimes not. I receive no errors stating what the problem is. <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO customer_tbl (customer_first_name, customer_last_name, customer_company, customer_ac, customer_phone, customer_fax_ac, customer_fax_phone, customer_email) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['customer_first_name'], "text"), GetSQLValueString($_POST['customer_last_name'], "text"), GetSQLValueString($_POST['customer_company'], "text"), GetSQLValueString($_POST['customer_ac'], "text"), GetSQLValueString($_POST['customer_phone'], "text"), GetSQLValueString($_POST['customer_fax_ac'], "text"), GetSQLValueString($_POST['customer_fax_phone'], "text"), GetSQLValueString($_POST['customer_email'], "text")); $customer_id = false; if(mysql_query($insertSQL, $connCid)) $customer_id = mysql_insert_id(); else echo "There was an error."; } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO quote_request_tbl (customer_id, quote_trans_date, quote_from_company, quote_from_address, quote_from_city, quote_from_state, quote_from_zip, quote_to_company, quote_to_address, quote_to_city, quote_to_state, quote_to_zip, quote_comments) VALUES ('$customer_id', %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['quote_trans_date'], "text"), GetSQLValueString($_POST['quote_from_company'], "text"), GetSQLValueString($_POST['quote_from_address'], "text"), GetSQLValueString($_POST['quote_from_city'], "text"), GetSQLValueString($_POST['quote_from_state'], "text"), GetSQLValueString($_POST['quote_from_zip'], "text"), GetSQLValueString($_POST['quote_to_company'], "text"), GetSQLValueString($_POST['quote_to_address'], "text"), GetSQLValueString($_POST['quote_to_city'], "text"), GetSQLValueString($_POST['quote_to_state'], "text"), GetSQLValueString($_POST['quote_to_zip'], "text"), GetSQLValueString($_POST['quote_comments'], "text")); $quote_id = false; if(mysql_query($insertSQL, $connCid)) $quote_id = mysql_insert_id(); else echo "There was an error."; } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1") && (isset($quote_id))) { $insertSQL = sprintf("INSERT INTO building_tbl (quote_id, building_quantity, building_width, building_length, building_height, building_overhang, slope_id, building_type_id, manufacture_id, foundation_id) VALUES ('$quote_id', %s, %s, %s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['building_quantity1'], "int"), GetSQLValueString($_POST['building_width1'], "int"), GetSQLValueString($_POST['building_length1'], "int"), GetSQLValueString($_POST['building_height1'], "int"), GetSQLValueString($_POST['building_overhang1'], "int"), GetSQLValueString($_POST['slope_id1'], "int"), GetSQLValueString($_POST['building_type_id1'], "int"), GetSQLValueString($_POST['manufacture_id1'], "int"), GetSQLValueString($_POST['foundation_id1'], "int"); mysql_select_db($database_connCid, $connCid); $Result1 = mysql_query($insertSQL, $connCid) or die(mysql_error()); header('Location: index.php?view=article&id=7'); } mysql_select_db($database_connCid, $connCid); $query_rsSlope = "SELECT * FROM slope_tbl ORDER BY slope_id ASC"; $rsSlope = mysql_query($query_rsSlope, $connCid) or die(mysql_error()); $row_rsSlope = mysql_fetch_assoc($rsSlope); $totalRows_rsSlope = mysql_num_rows($rsSlope); $query_rsSlope = "SELECT * FROM slope_tbl ORDER BY slope_id ASC"; $rsSlope = mysql_query($query_rsSlope, $connCid) or die(mysql_error()); $row_rsSlope = mysql_fetch_assoc($rsSlope); $totalRows_rsSlope = mysql_num_rows($rsSlope); mysql_select_db($database_connCid, $connCid); $query_rsBuildingType = "SELECT * FROM building_type_tbl ORDER BY building_type_id ASC"; $rsBuildingType = mysql_query($query_rsBuildingType, $connCid) or die(mysql_error()); $row_rsBuildingType = mysql_fetch_assoc($rsBuildingType); $totalRows_rsBuildingType = mysql_num_rows($rsBuildingType); mysql_select_db($database_connCid, $connCid); $query_rsManufacture = "SELECT * FROM manufacture_tbl ORDER BY manufacture_name ASC"; $rsManufacture = mysql_query($query_rsManufacture, $connCid) or die(mysql_error()); $row_rsManufacture = mysql_fetch_assoc($rsManufacture); $totalRows_rsManufacture = mysql_num_rows($rsManufacture); mysql_select_db($database_connCid, $connCid); $query_rsFoundation = "SELECT * FROM foundation_tbl ORDER BY foundation_name ASC"; $rsFoundation = mysql_query($query_rsFoundation, $connCid) or die(mysql_error()); $row_rsFoundation = mysql_fetch_assoc($rsFoundation); $totalRows_rsFoundation = mysql_num_rows($rsFoundation); ?> I belve the problem is in this part of the code: if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1") && (isset($quote_id))) Many thanks in advance.
  2. Hello PFMaBiSmAd Thanks for the response. I fiddled around with what you stated and combined what jim stated and ended up with the following: $colname_rsCustomers = "A"; if (isset($_GET['letterID'])) { $colname_rsCustomers = $_GET['letterID']; } mysql_select_db($database_connCid, $connCid); $query_rsCustomers = sprintf("SELECT * FROM customer_tbl WHERE customer_last_name LIKE '%s%%' ORDER BY customer_last_name ASC", mysql_real_escape_string($colname_rsCustomers)); $query_limit_rsCustomers = sprintf("%s LIMIT %d, %d", $query_rsCustomers, $startRow_rsCustomers, $maxRows_rsCustomers); $rsCustomers = mysql_query($query_limit_rsCustomers, $connCid) or die(mysql_error()); $row_rsCustomers = mysql_fetch_assoc($rsCustomers); Seems like everything is running smoothly. Thanks for the help. I'm happy to say this problem is solved.
  3. Thanks for the response jim. I get the following error when doing what you've stated: "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 'A'' ORDER BY customer_last_name ASC LIMIT 0, 10' at line 1" This is how my code looks: $colname_rsCustomers = "A"; if (isset($_GET['letterID'])) { $colname_rsCustomers = $_GET['letterID']; } mysql_select_db($database_connCid, $connCid); $query_rsCustomers = sprintf("SELECT * FROM customer_tbl WHERE customer_last_name LIKE '%%%s' ORDER BY customer_last_name ASC", GetSQLValueString($colname_rsCustomers, "text")); $query_limit_rsCustomers = sprintf("%s LIMIT %d, %d", $query_rsCustomers, $startRow_rsCustomers, $maxRows_rsCustomers); $rsCustomers = mysql_query($query_limit_rsCustomers, $connCid) or die(mysql_error()); $row_rsCustomers = mysql_fetch_assoc($rsCustomers); Any thoughts?
  4. I'm not an expert php programmer and I have been using Dreamweaver to produce PHP webpages. I have run into a problem producing a sql statement. $colname_rsCustomers = "A"; if (isset($_GET['letterID'])) { $colname_rsCustomers = $_GET['letterID']; } mysql_select_db($database_connCid, $connCid); $query_rsCustomers = sprintf("SELECT * FROM customer_tbl WHERE customer_last_name LIKE %s ORDER BY customer_last_name ASC", GetSQLValueString($colname_rsCustomers, "text")); $query_limit_rsCustomers = sprintf("%s LIMIT %d, %d", $query_rsCustomers, $startRow_rsCustomers, $maxRows_rsCustomers); $rsCustomers = mysql_query($query_limit_rsCustomers, $connCid) or die(mysql_error()); $row_rsCustomers = mysql_fetch_assoc($rsCustomers); I have been trying to produce this statement: SELECT * FROM customer_tbl WHERE customer_last_name LIKE 'A%' ORDER BY customer_last_name ASC The current code works with no errors. I don't know how to add the "%" without getting an error. So, the current code is only pulling last names that are "A" and I want last names that start with "A". I'd appreciate some help. Thanks in advance.
  5. I ended up using the code from teamatomic. I received no errors and the code works fine: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <?php $title; $path=$_SERVER['PHP_SELF']; $page=basename($path); switch("$page") { case 'index.php': $title = 'Welcome to the Home Page'; break; case 'page1.php': $title = 'This is the Page One'; break; case 'page2.php': $title = 'This is the Second Page'; break; } echo '<title>'.$title.'</title>'; ?> <link href="master.css" rel="stylesheet" type="text/css" /> </head> <body> <link href="master.css" rel="stylesheet" type="text/css" /> </head> <body> Thanks everybody. This is officially solved.
  6. I have a header, like so: header.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Website Page Title</title> <link href="master.css" rel="stylesheet" type="text/css" /> </head> <body> a footer like so: footer.php </body> </html> and several pages use the header and footer like so: index.php, page1.php, and page2.php <?php include("header.php"); ?> <p>Page Content</p> <?php include("footer.php"); ?> The only problem is that I can't change the page <title> for each page. I tried using this code to change the page <title>: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <?php $title; switch($_SERVER['PHP_SELF']) { case 'index.php': $title = 'Welcome to the Home Page'; break; case 'page1.php': $title = 'This is the Page One'; break; case 'page2.php': $title = 'This is the Second Page'; break; } echo '<title>'.$title.'</title>'; ?> <link href="master.css" rel="stylesheet" type="text/css" /> </head> <body> I get no errors but the title always comes out blank. Is there a better solution? or is this the code I should be using?
  7. Thank you HoTDaWg. Your code has sparked the correct idea and achieved what I wanted to do. With your insight I was able to produce the following code: <?php do { ?> <table border="1" width="100%"> <tr> <td><?php echo $row_rsVideoCat['video_cat']; ?> <?php echo $row_rsVideoCat['video_cat_id']; ?></td> </tr> <?php mysql_select_db($database_connDB, $connDB); $query_rsVideo = "SELECT * FROM video_tbl WHERE video_cat_id ='".$row_rsVideoCat['video_cat_id']."'"; $rsVideo = mysql_query($query_rsVideo, $connDB) or die(mysql_error()); $row_rsVideo = mysql_fetch_assoc($rsVideo); $totalRows_rsVideo = mysql_num_rows($rsVideo); ?> <?php do { ?> <tr> <td><?php echo $row_rsVideo['video_title']; ?></td> </tr> <?php } while ($row_rsVideo = mysql_fetch_assoc($rsVideo)); ?> </table> <br /> <?php } while ($row_rsVideoCat = mysql_fetch_assoc($rsVideoCat)); ?> Also, the code you gave me had some errors. I believe it goes something like this: <?php $connection = mysqli_connect('localhost','username','password','db_name'); $query = "SELECT * FROM video_cat_tbl"; $result = mysqli_query($connection,$query); while($row = mysqli_fetch_array($result)) { echo $row['video_cat'] . '<br>'; $query2 = "SELECT * FROM video_tbl WHERE video_cat_id ='".$row['video_cat_id']."' LIMIT 2"; $result2 = mysqli_query($connection, $query2); while($row2 = mysqli_fetch_array($result2)){ echo $row2['video_title'] . '<br>'; }; }; ?>
  8. I've been doing some research and I think what I need to do is combine the 2 recordsets in an array. I still don't know what I'm doing though. I'll keep looking until I find the correct answer or somebody provides me the correct answer.
  9. I have a video table and a video category table. The tables are pretty much set up like the following: video_tbl ------------ video_id video_title video_cat_id video_cat_tbl ----------------- video_cat_id video_cat I have 2 recordsets, 1 for each table, that use the following queries video table SELECT video_cat, video_title FROM video_tbl, video_cat_tbl WHERE video_cat_tbl.video_cat_id = video_tbl.video_cat_id video category table SELECT * FROM video_cat_tbl ORDER BY video_cat ASC And I'm using the following PHP code to display the data: <?php do { ?> <table border="1" width="100%"> <tr> <td colspan="2"><?php echo $row_rsVideoCat['video_cat']; ?></td> </tr> <?php do { ?> <tr> <td><?php echo $row_rsVideo['video_title']; ?></td> </tr> <?php } while ($row_rsVideo = mysql_fetch_assoc($rsVideo)); ?> </table> <br /> <?php } while ($row_rsVideoCat = mysql_fetch_assoc($rsVideoCat)); ?> Using the code above the data displays like this Video Category 1 -------------------- Video 1 Video 2 Video 3 Video 4 Video Category 2 --------------------- But I want it to display like this: Video Category 1 -------------------- Video 1 Video 2 Video Category 2 --------------------- Video 3 Video 4 How do I display all the categories with with their specific Items under them?
  10. alright, I'll have to look into this. Thanks for helping a newb.
  11. I forgot to mention that I'm using MySQL client version 5.0.75
  12. I've been hitting my head against the wall trying to figure this out. I have a video table and a video category table. The tables are pretty much set up like the following: video_tbl ------------ video_id video_title video_cat_id video_cat_tbl ----------------- video_cat_id video_cat I wrote this query and it works fine. SELECT video_cat, video_title FROM video_tbl, video_cat_tbl WHERE video_cat_tbl.video_cat_id = video_tbl.video_cat_id The only problem is that the category appears in every row, as it should. I want it to appear only once. Something like the following. Video Category 1 -------------------- Video 1 Video 2 Video Category 2 --------------------- Video 3 Video 4 I'm trying to create a recordset that will display the videos under a certain category. I was looking into using GROUP BY, DISTINCT, or JOIN in the SQL query but I can't figure out what to do. I'd appreciate the help.
  13. Is anyone gonna hook me up with a solution to this problem? I'd really appreciate.
  14. I'm trying to get the data in my database to display in my RSS Feed but there's supposedly an error in my code. My web browser says it's the "mysql_fetch_array()" in my code where it says "while($row = mysql_fetch_array($result))" in the private function getDetails(). I found this code on the net and modified it to suit my needs. Seems like I don't know what I'm doing though. Can someone help me out? Here's the full code I'm using: This is the code that grabs the items for the RSS Feed: <?php class RSS { public function RSS() { require_once ('Connections/mysql_connect.php'); } public function GetFeed() { return $this->getDetails() . $this->getItems(); } private function dbConnect() { DEFINE ('LINK', mysql_connect (DB_HOST, DB_USER, DB_PASSWORD)); } private function getDetails() { $colname_rsShops = "1"; if (isset($_GET['stateID'])) { $colname_rsShops = $_GET['stateID']; } $detailsTable = "shop_tbl, state_lookup_tbl"; $this->dbConnect($detailsTable); $query = "SELECT * FROM ". $detailsTable ."WHERE shop_state = ". $colname_rsShops ."AND shop_tbl.shop_approved = 1 AND shop_state = state_lookup_tbl.state ORDER BY shop_tbl.shop_name ASC"; $result = mysql_db_query (DB_NAME, $query, LINK); while($row = mysql_fetch_array($result)) { $details = '<?xml version="1.0" encoding="ISO-8859-1" ?> <rss version="2.0"> <channel> <title>Anime Shops In '. $row['full_state'] .'</title> <link>http://www.otakuwanted.com</link> <description>Find And Reveiw Anime Shops Near You At Otaku Wanted. Anime Shops In '. $row['full_state'] .'</description> <language></language> <image> <title></title> <url></url> <link></link> <width></width> <height></height> </image>'; } return $details; } private function getItems() { $colname_rsShops = "1"; if (isset($_GET['stateID'])) { $colname_rsShops = $_GET['stateID']; } $itemsTable = "shop_tbl, state_lookup_tbl"; $this->dbConnect($itemsTable); $query = "SELECT * FROM ". $itemsTable ."WHERE shop_state = ". $colname_rsShops ."AND shop_tbl.shop_approved = 1 AND shop_state = state_lookup_tbl.state ORDER BY shop_tbl.shop_name ASC"; $result = mysql_db_query (DB_NAME, $query, LINK); $items = ''; while($row = mysql_fetch_array($result)) { $items .= '<item> <title>'. $row["shop_name"] .'</title> <link>http://www.otakuwanted.com/shopselect.php?shopID='. $row["shop_id"] .'</link> <description></description> </item>'; } $items .= '</channel> </rss>'; return $items; } } ?> This is the code that's supposed to display all code above: <?php header("Content-Type: application/xml; charset=ISO-8859-1"); include("classes/RSS.class.php"); $rss = new RSS(); echo $rss->GetFeed(); ?>
  15. That's good to know. How do I fix this issue?
×
×
  • 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.