Jump to content

Skatecrazy1

Members
  • Posts

    126
  • Joined

  • Last visited

Everything posted by Skatecrazy1

  1. I'm used to OOP, but haven't used it much with PHP so the syntax and declarations are a bit hazy. Used it more often with C++ and Java, and whatever bastardized version of C++ arduino runs off of. I have used mysqli in the past so I do know that there are a few things that are different, how it takes arguments, etc. I am trying to get a basic grasp back on OOP syntax and database querying with php after being gone from it for years working in an industrial occupation. Currently rewriting my code with more updated syntax and function libraries. Having issues declaring protected or public variables as they seem to go undefined when it comes time to call them. Now bear with me, declaring your own constructors wasn't really necessary back when I was at it, so I'm still trying to wrap my head around the concept of it. I seem to be failing pretty hard. This code throws me an "UNEXPECTED T_VARIABLE" on line 6. <?php class Sql { protected $host, $user, $pass, $db; $host = "localhost"; $user = "admin"; $pass = ""; $db = "blog"; public function __construct($host, $user, $pass, $db){ $this->host = $host; $this->user = $user; $this->pass = $pass; $this->db = $db; $conn = mysqli_connect($host, $user, $pass); mysqli_select_db($db); } public function userData() { $sql = "SELECT * FROM users"; $result = mysqli_query($conn, $sql); $num = mysqli_num_rows($result); for($i = 0; $i < $num; $i++){ $data = mysqli_fetch_array($result); echo $data['name']; echo " | "; echo $data['email']; echo " | "; echo $data ['phone']; echo "<br />"; } } } ?>
  2. Is mysql improved expected to be supported for any length of time? It's closer to what I'm used to. The OOP is terrible because I used to write scripts back in the PHP2-3 days and never used objects with any frequency.
  3. Guess not. Was using the older code because that's what I remember off the top of my head. I'll seek help elsewhere, then. So long phpfreaks, you used to be cool.
  4. Thanks for making my point for me. I'm using it because I haven't written any code in a few years. Anyone on this forum who actually wants to look at my code ? Or has there been a large influx of pompous twits in the couple years I've been gone and no one actually helps out here anymore?
  5. Can you actually elaborate? What parts of my code are obsolete? Try being helpful instead of just confirming what I already know. For what it's worth the code was working perfectly fine until I imported everything into the new db.
  6. So I'm just starting this little side project to mess around with the idea of a torrent tracker site. I'm a little rusty with my hand-typed scripts so I'm sure I'm looking right at something here and missing it. Just trying to display table data from 'users'. Worked just fine while I ran it on the test db, but after exporting it from the test db and importing it into the actual db I'm using I get a boolean returned for my $result, which causes my num_rows to fail and throw an error. Thanks in advance for any help. <?php class Sql { public function __construct(){ global $host, $user, $pass, $db, $conn; $host = "localhost"; $user = "admin"; $pass = ""; $db = "blog"; $conn = mysql_connect($host, $user, $pass); mysql_select_db($db); } } class Connect extends Sql { //connect function and verification public function init(){ //this function connects to the database based on //global variables defined in the "Sql" class // globals global $user, $pass, $conn, $host, $db; if(!$conn){ print "Connection failed."; } else { print "<div id = \"connect\">"; print "SQL Connection Successful"; print "</div>"; } } } class Display extends Sql { //this class selects and displays data from a given table public function user_display(){ // globals global $conn; $sql = "SELECT * FROM users"; $result = mysql_query($sql, $conn); if(!$result){ echo $result; } $num = mysql_num_rows($result); echo " <table padding=\"3\" border=\"1\"> <tr> <td> <strong>Name</strong> </td> <td> <strong>Email</strong> </td> <td> <strong>Phone</strong> </td> </tr>"; //loop through the data for($i = 0; $i < $num; $i++){ $data = mysql_fetch_array($result); echo " <tr> <td> ".$data['name']." </td> <td> ".$data['email']." </td> <td> ".$data['phone']." </td> </tr>"; } mysql_close($conn); } } ?>
  7. having a problem using get variables to include certain pages. I have a management script for a news feed that uses get variables to display certain parts of the script. here is the template/ main part of the script <?php session_start(); require_once("vars.php"); $username = $_SESSION['username']; $is_admin = $_SESSION['is_admin']; $referer = $_SERVER['HTTP_REFERER']; //check to see if user is logged in and is an administrator if((isset($_SESSION['username'])) && ($_SESSION['is_admin'] == 1)){ //if all session variables are set, display admin panel ?> <html> <head> <title>Administration</title> <link rel="stylesheet" type="text/css" href="/cameo/css/admin.css" media="screen" /> </head> <body> <table cellspacing="0" cellpadding="3" class="layout"> <tr> <td colspan="2"><h3>Administration</h3></td> </tr> <tr> <td valign="top"> <a href="index.php?pg=news">Manage News Feed</a> </td> <td> <?php $id = $_GET['pg']; switch($id){ case news: include("manage_news.php"); case editpost: include('edit_post.php'); break; } ?> </td> </tr> </table> </body> </html> <?php } else { echo("You do not have permission to view this page. <br />"); echo("<a href=\"".$referer."\">Go Back</a>"); } ?> and heres the edit post page that the script refers to <?php require_once("vars.php"); $id = $_GET['id']; $query = "SELECT * FROM news_feed WHERE id=".$id; $result = mysqli_query($dbc,$query); $row = mysqli_fetch_array($result); ?> <form method="post" action="update.php"> <textarea><?php echo $row['post_body']; ?></textarea> </form> now, for some reason, the edit post form is showing up under the main news feed listing, even though the get id does not match the one in the switch statement. thanks in advance for any help
  8. nevermind, double checked the database and the data somehow got duplicated, thanks for all the help guys
  9. k, finally got it working, but the 2 test rows I created are being displayed twice. once again, here is the code: <?php require_once("vars.php"); //write the query to get the news feed info from the database $query = "SELECT * FROM news_feed"; $result = mysqli_query($dbc, $query); //create beginning tags for the news data table $output = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" name=\"news_data\">"; //display the news feed data while($row = mysqli_fetch_array($result)){ $output .= "<tr>" ."<td><h3>".$row['post_title']."</h3>" ."<br />Posted by: ".$row['posted_by']." on ".$row['date']."</td>" ."</tr>" ."<tr>" ."<td>".$row['post_body']."</td>" ."</tr>"; } $output .= "</table>"; echo $output; ?>
  10. umm, i got an answer as to why my code's not working, but nothing on how to fix it, i tried incrementing the row's id field as such: <?php require_once("vars.php"); //write the query to get the news feed info from the database $query = "SELECT * FROM news_feed WHERE "; $result = mysqli_query($dbc, $query); //create beginning tags for the news data table $output = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" name=\"news_data\">"; //display the news feed data while($row = mysql_fetch_array($result)){ $row_id = $row['id']; $output .= "<tr>" ."<td><h3>".$row['post_title']."</h3>" ."<br />Posted by: ".$row['posted_by']." on ".$row['date']."</td>" ."</tr>" ."<tr>" ."<td>".$row['post_body']."</td>" ."</tr>"; $row_id++; } $output .= "</table>"; echo $output; ?> now I get this error, which by the way i've been getting a lot lately and it's quite annoying, I've used the same mysql_fetch_array parameters for years and the function is just now giving me problems, happens with select_db and mysql_connect as well: Warning: mysql_fetch_array() expects parameter 1 to be resource, object given in /Applications/XAMPP/xamppfiles/htdocs/cameo/newsfeed.php on line 10 any help would be appreciated as I have a loose deadline coming up soon on this
  11. oh okay, but wouldn't while(mysql_num_rows($result)) keep fetching rows until the statement is null?
  12. Hey, was just writing rough code for a news feed script, and this error came up: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 133693565 bytes) in /Applications/XAMPP/xamppfiles/htdocs/cameo/newsfeed.php on line 17 here's the code <?php require_once("vars.php"); //write the query to get the news feed info from the database $query = "SELECT * FROM news_feed"; $result = mysqli_query($dbc, $query); //create beginning tags for the news data table $output = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" name=\"news_data\">"; //display the news feed data $row = mysqli_fetch_array($result); while($row){ $output .= "<tr>" ."<td><h3>".$row['post_title']."</h3>" ."<br />Posted by: ".$row['posted_by']." on ".$row['date']."</td>" ."</tr>" ."<tr>" ."<td>".$row['post_body']."</td>" ."</tr>"; } $output .= "</table>"; echo $output; ?> and heres my vars file if needed <? //common session variables $username = $_SESSION['username']; $is_admin = $_SESSION['is_admin']; //database connection information variables $server = "localhost"; $user = "root"; $pass = ""; $db = "cameo"; //database function variables $dbc = mysqli_connect($server, $user, $pass, $db); //http header and script return variables $index = "/cameo/index.php"; $self = $_SERVER['PHP_SELF']; ?>
  13. shooot, now i'm running this code: <?php session_start(); //sql variables $server = "localhost"; $user = "root"; $pass = ""; $db = "cameo"; //iff user isn't logged in, try to log them in if(!isset($_SESSION['username'])){ if(isset($_POST['submit'])){ //connect to database $dbc = mysqli_connect($server, $user, $pass, $db); //grab entered form data $user_username = mysqli_real_escape_string($dbc, trim($_POST['username'])); $user_password = mysqli_real_escape_string($dbc, trim($_POST['username'])); //if both username and password are entered then find a match in the database if((!empty($user_username)) && (!empty($user_password))) { //look up the username and password in the database $query = "SELECT * FROM users WHERE username = '$user_username' AND '$user_password'"; $data = mysqli_query($dbc, $query); //authenticate if data matches a row if(mysqli_num_rows($data) == 1){ //login is okay $row = mysqli_fetch_array($data); $_SESSION['username'] = $row['username']; $_SESSION['is_admin'] = $row['is_admin']; header('Location:index.php'); } else { //username and password are incorrect or missing, so send a message $error_msg = 'Sorry, you must enter a valid username and password to log in.'; } } } } ?> and the script is working but I come up with a blank page and the header redirect back to index isn't working
  14. ah, i referenced the database name rather than the table in the query
  15. um added another curly bracket at the end, now i get this error: Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\Program Files\xampp\htdocs\cameo\login.php on line 26 numrows shouldn't return a boolean should it? this is quite confusing it should just return the number of rows found not a true/false
  16. I know this is probably a missing curly bracket or some other syntax, but I can't seem to spot it, anyone see it? i get this error btw. Parse error: syntax error, unexpected $end in C:\Program Files\xampp\htdocs\cameo\login.php on line 39 <?php session_start(); //sql variables $server = "localhost"; $user = "root"; $pass = ""; $db = "cameo"; //iff user isn't logged in, try to log them in if(!isset($_SESSION['username'])){ if(isset($_POST['submit'])){ //connect to database $dbc = mysqli_connect($server, $user, $pass, $db); //grab entered form data $user_username = mysqli_real_escape_string($dbc, trim($_POST['username'])); $user_password = mysqli_real_escape_string($dbc, trim($_POST['username'])); //if both username and password are entered then find a match in the database if((!empty($user_username)) && (!empty($user_password))) { //look up the username and password in the database $query = "SELECT username FROM cameo WHERE username = '$user_username' AND '$user_password'"; $data = mysqli_query($dbc, $query); //authenticate if data matches a row if(mysqli_num_rows($data) == 1){ //login is okay $row = mysqli_fetch_array($data); $_SESSION['username'] = $row['username']; $_SESSION['is_admin'] = $row['is_admin']; header('Location:index.php'); } else { //username and password are incorrect or missing, so send a message $error_msg = 'Sorry, you must enter a valid username and password to log in.'; } } } ?>
  17. basically i want to have two of these auction registration pages, however, oscommerce only allows me to use one file, live_auctions.php, so i figured i'd make a dropdown that took you to one reg form or the other depending on input, but keep it in the same file. heres the code, the problem i'm having is that i can't get the form action="<? $_SERVER['PHP_SELF']; ?>"> to direct the form input back to the file (within the define() function) and output one of the two html options i have thanks in advance for any help at all -dakota <?php $auction = $_POST['auction']; define("NAVBAR_TITLE", "PREMIERE PROPS LIVE AUCTIONS!"); define("HEADING_TITLE", "PREMIERE PROPS LIVE AUCTIONS!"); define('BASE_HTML', ' <table cellspacing="0" cellpadding="2" border="0"> <tr> <td><img src="http://www.premiereprops.com/auctions/2hlw/hlw2_billboard.jpg" width="530" height="252" /></td> </tr> <tr> <td> <form method="post" action="live_auctions.php"> <table cellspacing="0" cellpadding="2"> <tr> <td> <select name="auction"> <option selected>Choose a live auction!</option> <option value="car">Massive Car Auction</option> <option value="2hlw">HUGE Halloween II Auction</option> </select> </td> <td> <input type="submit" value="Register Now" /> </td> </tr> </table> </form> </td> </tr> <tr> <td><img src="http://www.premiereprops.com/auctions/car_auction/ca_billboard.png" width="530" height="252" /></td> </tr> </table> '); define('CAR_HTML', ' </style> </head> <p align="center"><img border="0" src="https://www.premiereprops.com/auctions/car_auction/ca_billboard.png" alt="CAR AUCTION AUGTUST 1 & 8!" width="530" ><br /></A> </p> <p><font face="Tahoma"><span style="font-size: 10pt;"> Premiere Props will be auctioning off iconic cars from fan favorite movies for one weekend only! In partnership with TedMoser of Picture Car Warehouse, Premiere Props will be auctioning off over 100 iconic cars from acclaimed Hollywood movies as well as hotrods and classic cars from Picture Car Warehouse\'s collection on August 15th at LA Center Studios in Los Angeles, California (1201 West 5th Street, LA, CA 90017) at 11am with a preview from 9am - 11am. </span><b> <br /><br /><font size="2">OVER 100 ICONIC CARS UP FOR BID</font></b></font></p> <p><font face="Tahoma"><span style="font-size: 10pt;">Premiere Props and Picture Car Warehouse will auction off one-of-a-kind automobiles from box office hit films including "Little Miss Sunshine," "Unthinkable," "Indiana Jones," "The Great Debaters," "Redline," "Slipstream," "Knight Rider," "Sand Boys," "Soul Men," "No Country For Old Men," "Holiday," "Bruce Almighty," "Fast and Furious," "Rush Hour 3," "Mad Men," "Taxi," and many, many more!</span></font></p> <p style="font-size:16px; color:#1A0880; font-weight:bold">REGISTER NOW:</p> <p> We invite you to be part of our exciting live auction events and registering online is simple. You must register in order to place bids on all available items. We have set up the following three methods to place a bid: <br /> </p> <ol> <li><font color="#1A0880"><strong>Live Auction Online bidding:</strong></font> This option of registration is for those that will be placing bids via the internet. You may register for online bidding by visiting the iCollector webpage: <a href=http://www.icollector.com/Massive-Car-Auction-Movie-Cars-Hot-Rods-Classics_as14761" target="_blank">www.icollector.com</a>.<br /> <br /> </li> <li><font color="#1A0880"><strong>Live Auction Phone bidding:</strong></font> This option of registration is for those that will be placing bids via telephone. You may register for telephone bidding using the form below<em> (scroll down)</em>.<br /> <br /> </li> <li> <font color="#1A0880"><strong>Live Auction In-person bidding:</strong></font> This option of registration is for those that will be placing bids in-person. If you would like to come and visit in person, then register using the form below <em>(scroll down)</em>. You can never register too early so do it now!: </li> </ol> <p align="center" style="font-size:14px; color:#1A0880; font-weight:bold">:: <a href="http://www.icollector.com/Massive-Car-Auction-Movie-Cars-Hot-Rods-Classics_as14761">See Item Catalog For This Auction</a> ::</p> <center> <table width="100%" border="0"> <tr> <td><form enctype="multipart/form-data" action="http://www.premiereprops.com/ppformz/use/passions_register/process.php" method="post"> <div align="center"> <table width="90%" border="0" cellspacing="10"> <tr> <td align="right"><span style="font-size:13px"><strong>* I am registering for:</strong></span></td> <td align="left"><span style="font-size:13px">Phone Bidding <input type="radio" name="typebid" value="phone" /> In-Person Bidding <input type="radio" name="typebid" value="inperson" /></span></td> </tr> <tr> <td width="35%" align="right"><br /> * <span style="font-size:13px"><strong>First Name:</strong></span></td> <td width="65%" align="left"><br /> <input name="firstname" type="text" size="25" /></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Middle Initial:</strong></span></td> <td align="left"><input name="middleinitial" type="text" size="2" maxlength="1" /></td> </tr> <tr> <td align="right">* <span style="font-size:13px"><strong>Last Name:</strong></span></td> <td align="left"><input name="lastname" type="text" size="25" /></td> </tr> <tr> <td align="right">* <span style="font-size:13px"><strong>E-mail:</strong></span></td> <td align="left"><input name="email" type="text" size="30" /></td> </tr> <tr> <td align="right">* <span style="font-size:13px"><strong>Billing Address:</strong></span></td> <td align="left"><input name="billingaddress" type="text" size="30" /></td> </tr> <tr> <td align="right">* <span style="font-size:13px"><strong>City:</strong></span></td> <td align="left"><input name="city" type="text" size="25" /></td> </tr> <tr> <td align="right">* <span style="font-size:13px"><strong>State:</strong></span></td> <td align="left"><input name="state" type="text" size="25" /></td> </tr> <tr> <td align="right">* <span style="font-size:13px"><strong>Zip Code:</strong></span></td> <td align="left"><input name="zipcode" type="text" size="6" maxlength="5" /></td> </tr> <tr> <td align="right">* <span style="font-size:13px"><strong>Primary Phone:</strong></span></td> <td align="left"><input name="primaryphone" type="text" size="15" /> <span style="font-size:13px">(e.g. 123-123-1234)</span></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Secondary Phone:</strong></span></td> <td align="left"><input name="secondaryphone" type="text" size="15" /> <span style="font-size:13px">(e.g. 123-123-1234)</span></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Fax Number:</strong></span></td> <td align="left"><input name="faxnumber" type="text" size="15" /> <span style="font-size:13px">(e.g. 123-123-1234)</span></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Company Name:</strong></span></td> <td align="left"><input name="companyname" type="text" size="25" /></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Title:</strong></span></td> <td align="left"><input name="title" type="text" size="30" /></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Website URL:</strong></span></td> <td align="left"><input name="websiteurl" type="text" size="30" /></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Resale Tax ID:</strong></span></td> <td align="left"><input name="resaletaxid" type="text" size="15" /></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Issuing State:</strong></span></td> <td align="left"><input name="issuingstate" type="text" size="25" /> <span style="font-size:11px"><br /> Please bring a copy of your Tax Permit on Auction Day.</span></td> </tr> <tr> <td align="right"></td> <td><b>* = Required<br /> <br /> </b></td> </tr> <tr> <td colspan="2"><p align="center"> <input type="submit" value="Submit Registration" /> </p></td> </tr> <tr> <td colspan="2"><p align="center"> </p></td> </tr> <tr> <td colspan="2"></td> </tr> </table> </div> </form></td> </tr> </table> </center> '); define('HLW_HTML', ' </style> </head> <p align="center"><img border="0" src="http://www.premiereprops.com/auctions/2hlw/hlw2_billboard.jpg" alt="ROB ZOMBIE’S HALLOWEEN II LIVE AUCTION ON AUGUST 29TH !" width="530" ><br /></A> </p> <p> <b><font size="2">ROB ZOMBIE’S HALLOWEEN II LIVE AUCTION ON AUGUST 29TH !</font></b> </p> <p>Premiere Props will be auctioning off over 500 props and costumes from Rob Zombie’s Halloween II on August 29th at 11am with a preview from 9am - 11am. The auction will be broadcast live on TV and online! Plus don’t miss the special guest appearances, soon to be announced. <span style="font-size: 10pt;"> </span></p> <span style="font-size: 10pt;"> <p> Proceeds Benefit The Entertainment Industry Foundation.</p> </span><b> <p style="font-size:16px; color:#1A0880; font-weight:bold">REGISTER NOW:</p> <p> We invite you to be part of our exciting live auction events and registering online is simple. You must register in order to place bids on all available items. We have set up the following three methods to place a bid: <br /> </p> <ol> <li><font color="#1A0880"><strong>Live Auction Online bidding:</strong></font> This option of registration is for those that will be placing bids via the internet. You may register for online bidding by visiting the iCollector webpage: <a href=http://www.icollector.com/Massive-Car-Auction-Movie-Cars-Hot-Rods-Classics_as14761" target="_blank">www.icollector.com</a>.<br /> <br /> </li> <li><font color="#1A0880"><strong>Live Auction Phone bidding:</strong></font> This option of registration is for those that will be placing bids via telephone. You may register for telephone bidding using the form below<em> (scroll down)</em>.<br /> <br /> </li> <li> <font color="#1A0880"><strong>Live Auction In-person bidding:</strong></font> This option of registration is for those that will be placing bids in-person. If you would like to come and visit in person, then register using the form below <em>(scroll down)</em>. You can never register too early so do it now!: </li> </ol> <p align="center" style="font-size:14px; color:#1A0880; font-weight:bold">:: <a href="http://www.icollector.com/Massive-Car-Auction-Movie-Cars-Hot-Rods-Classics_as14761"">See Item Catalog For This Auction</a> ::</p> <center> <table width="100%" border="0"> <tr> <td><form enctype="multipart/form-data" action="http://www.premiereprops.com/ppformz/use/passions_register/process.php" method="post"> <div align="center"> <table width="90%" border="0" cellspacing="10"> <tr> <td align="right"><span style="font-size:13px"><strong>* I am registering for:</strong></span></td> <td align="left"><span style="font-size:13px">Phone Bidding <input type="radio" name="typebid" value="phone" /> In-Person Bidding <input type="radio" name="typebid" value="inperson" /></span></td> </tr> <tr> <td width="35%" align="right"><br /> * <span style="font-size:13px"><strong>First Name:</strong></span></td> <td width="65%" align="left"><br /> <input name="firstname" type="text" size="25" /></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Middle Initial:</strong></span></td> <td align="left"><input name="middleinitial" type="text" size="3" maxlength="1" /></td> </tr> <tr> <td align="right">* <span style="font-size:13px"><strong>Last Name:</strong></span></td> <td align="left"><input name="lastname" type="text" size="25" /></td> </tr> <tr> <td align="right">* <span style="font-size:13px"><strong>E-mail:</strong></span></td> <td align="left"><input name="email" type="text" size="30" /></td> </tr> <tr> <td align="right">* <span style="font-size:13px"><strong>Billing Address:</strong></span></td> <td align="left"><input name="billingaddress" type="text" size="30" /></td> </tr> <tr> <td align="right">* <span style="font-size:13px"><strong>City:</strong></span></td> <td align="left"><input name="city" type="text" size="25" /></td> </tr> <tr> <td align="right">* <span style="font-size:13px"><strong>State:</strong></span></td> <td align="left"><input name="state" type="text" size="25" /></td> </tr> <tr> <td align="right">* <span style="font-size:13px"><strong>Zip Code:</strong></span></td> <td align="left"><input name="zipcode" type="text" size="6" maxlength="5" /></td> </tr> <tr> <td align="right">* <span style="font-size:13px"><strong>Primary Phone:</strong></span></td> <td align="left"><input name="primaryphone" type="text" size="15" /> <span style="font-size:13px">(e.g. 123-123-1234)</span></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Secondary Phone:</strong></span></td> <td align="left"><input name="secondaryphone" type="text" size="15" /> <span style="font-size:13px">(e.g. 123-123-1234)</span></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Fax Number:</strong></span></td> <td align="left"><input name="faxnumber" type="text" size="15" /> <span style="font-size:13px">(e.g. 123-123-1234)</span></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Company Name:</strong></span></td> <td align="left"><input name="companyname" type="text" size="25" /></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Title:</strong></span></td> <td align="left"><input name="title" type="text" size="30" /></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Website URL:</strong></span></td> <td align="left"><input name="websiteurl" type="text" size="30" /></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Resale Tax ID:</strong></span></td> <td align="left"><input name="resaletaxid" type="text" size="15" /></td> </tr> <tr> <td align="right"><span style="font-size:13px"><strong>Issuing State:</strong></span></td> <td align="left"><input name="issuingstate" type="text" size="25" /> <span style="font-size:11px"><br /> Please bring a copy of your Tax Permit on Auction Day.</span></td> </tr> <tr> <td align="right"></td> <td><b>* = Required<br /> <br /> </b></td> </tr> <tr> <td colspan="2"><p align="center"> <input type="submit" value="Submit Registration" /> </p></td> </tr> <tr> <td colspan="2"><p align="center"> </p></td> </tr> <tr> <td colspan="2"></td> </tr> </table> </div> </form></td> </tr> </table> </center> '); //this chooses what is shown on the page depending on post input if(isset($auctiontype)){ if($auctiontype == "car"){ define('TEXT_INFORMATION', CAR_HTML); } elseif($auctiontype == "2hlw"){ define('TEXT_INFORMATION', HLW_HTML); } } else { define('TEXT_INFORMATION', BASE_HTML); } //------------------------------------------------// ?>
  18. yeah, and if you don't want to do it that way, then in MySQL, you create the field as a BLOB binary large object (or a bigblob, tinyblob). Then if you have phpMyAdmin, go to insert and just basically do what you would to upload a file into a form. calling it's a different story, I don't have that figured out yet :-p
  19. [url=http://www.phpfreaks.com/tutorials/5/0.php]http://www.phpfreaks.com/tutorials/5/0.php[/url]
  20. elaborate.  are the checkbox values integers, varchar, etc. do you want to filter out the values from what gets entered in a form? again, just be more specific.
  21. well i'm pretty well successfully creating a news system for myself, but i'm making it so it's simple enough that i can offer it as an open source script on my site once it's done. well, i'm having problems viewing comments, for instance here's the class file from my show news [code] <?php /* show_news.php this file will show the news, with comments. */ //require db file created by installation require('db.php'); class ShowNews {       var $amt;             function show_news($amt)       {         $self = $_SERVER['PHP_SELF'];               require('db.php');               //create dynamic sql based on func argument               $sql = "SELECT * FROM `posts` ORDER BY `id` DESC LIMIT $amt";               //query it up               $rs = @mysql_query($sql, $conn) or die(mysql_error());               while($row = mysql_fetch_array($rs)){                 //fetch no. of comments posted about this article                 $comm = "SELECT * FROM `comments` WHERE `postid`=\"".$row['id']."\"";                 $c_rs = @mysql_query($comm, $conn) or die(mysql_error());                   //fetch number of comments here                   $c_num = mysql_num_rows($c_rs);                   $news .= "<p>";                   $news .= "<table cellspacing=\"2\" cellpadding=\"4\" border=\"1\">";                   $news .= "<tr><td>";                   $news .= "<h3>".$row['title']."</h3>";                   $news .= "</td></tr>";                   $news .= "<tr><td>".$row['body']."</td></tr>";                   $news .= "<tr><td><i>By ".$row['author'].", on ".$row['timestamp']."</i></td></tr>";                   $news .= "<tr><td><div align=\"right\"><i><a href=\"$self?comm=".$row['id']."\">".$c_num." Comments</div></td></tr>";                   $news .= "</table>";                   $news .= "</p>";               }                             echo $news;                     }       } //set GET value based on link we made previously $id = $_GET['comm']; //write query that will grab the post based on the link we clicked   $grab_post = "SELECT * FROM `posts` WHERE `id`=\"$id\" LIMIT 1";   $result = @mysql_query($grab_post, $conn) or die(mysql_error());   //write query to grab comments for this specific post   $grab_comm = "SELECT * FROM `comments` WHERE `postid`=\"$id\" ORDER BY `id` DESC";   $gb_rs = @mysql_query($grab_comm, $conn) or die(mysql_error());   $news .= "<p>";   $news = "<table cellspacing=\"2\" cellpadding=\"4\" border=\"1\">";   $news .= "<tr><td>";   $news .= "<h3>".$row['title']."</h3>";   $news .= "</td></tr>";   $news .= "<tr><td>".$row['body']."</td></tr>";   $news .= "<tr><td><i>By ".$row['author'].", on ".$row['timestamp']."</i></td></tr>";   $news .= "</table>";   $news .= "</p>";   //start building comment part of table   $news .= "<p>";   $news .= "<table cellspacing=\"2\" cellpadding=\"4\" border=\"1\" background=\"teal\">";   while($row = mysql_fetch_array($gb_rs))   {     $link = $row['email'];     $news .= "<tr><td>";     if($link != null){       $news .= "<a href=\"mailto:$link\">".$row['name']."</a>";       } else {       $news .= $row['name'];       }     $news .= "</td></tr>";     $news .= "<tr><td>".$row['body']."</td></tr>";   }     $news .= "</table>";     echo $news; ?> [/code] and the file it's being run on: [code] <?php include('show_news.php'); $news = new ShowNews; $news->show_news(2); ?>[/code] i'm having a hard time viewing the comments separately without having to use a separate file, based on the GET values in the links any help appreciated.
  22. no, the straight up php installation isn't for a beginner do what roopurt advised and just get xampp it's very easy to use, everything's automatic
  23. well I know this is probably very easily looked up, but I'm short on time; is there any way to call the names of all the fields in a table into an array? thanks.
×
×
  • 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.