Jump to content

jcbones

Staff Alumni
  • Posts

    2,653
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by jcbones

  1. What you need to do is take the WHERE clause out of all of your queries. drapedbustquery.php through walkingquery.php has queries in them, look for the where clause in each files query. Add a hidden field to each form (this is because IE doesn't pass name attributes with image inputs, IIRC), and make sure they are all the same name (type). Notice the empty action attribute. <form id="drapedbusthalves" name="drapedbusthalves" method="post" action=""> <input type="hidden" name="type" value="drapedbusthalves" /> <input type="image" src="images/Draped-Bust-Halves.jpg" alt="SUBMIT" width="330" height="22" /> </form> Then make you a switch statement, and check for the type index in your post query. <?php $where = NULL; //where is built but is empty (NULL). if(!empty($_POST['type'])) { //if the form is sent with the right named input. $where = 'WHERE '; //where starts to build the WHERE clause. switch($_POST['type']) { //switch the variable depending on the case. case: 'drapedbusthalves'; //if this is the contents of the type input element. $where .= ''; //this is where you put the "WHERE" clause from the corresponding drapedbustquery.php break; //dont' forget to end the switch here. case: 'cappedbusthalves'; //else if this is the contents of the input element "type". $where .= ''; //this is where you put the "WHERE" clause from the corresponding cappedbustquery.php break; //always break the switch at the end of case arguments for this switch (there are reasons not to do this, but in this switch you will need to). //etc... //continue until all cases are made. } } Then you need to add one more thing. The where clause to the query. <?php $query = ("SELECT * FROM listings $where" ); //add the where clause we built with the switch to the query. This will be empty (showing a full page) if no button is pushed.
  2. Yes, PHP prints exactly what you ask it to. While it may show a single line in the source, the browser will read the HTML, and output it correctly. If this is still an issue, you can look into adding line breaks with \n or \r\n. Or, you could use the php constant PHP_EOL. <?php //examples. echo 'Create a line break' . "\n" . 'before this line!'; //notice that the line break must be enclosed in double quotes. echo "Yes it will\nwork here too"; echo "This will" . PHP_EOL . 'also work';
  3. You don't need a index in your form. while ($rows = mysql_fetch_array($SqlResult)); ?> <td align="center" bgcolor="#FFFFFF"><input name="need_delete[]" type="checkbox" id="checkbox[<? echo $rows['Gbk_Id']; ?>]" value="<? echo $rows['Gbk_Id']; ?>"></td> <?php Should be fine. Remove_Message() is returing a string of "False". It also has no database interaction, just sets a string in the form of a query.
  4. So, how is your table in the database set up? IMHO, you should have relational tables. How many would depend on just how far this application goes.
  5. Fix the database query. The resource is being returned as a boolean. The only time mysql_query returns a boolean is if it is false, which means it failed, which means there is an error associated with it. Surely you have seen this same thread topic before, there is usually 1 per day.
  6. Localhost means exactly that, the local server. Meaning the server that resides on the machine that you are accessing. Each server is local to somewhere. If port 80 (default http port) is opened, anyone can access the server (theoretically).
  7. For a small site, I tend to steer clear of typed captcha's, and prefer other forms of form security. Tokens, honeypots, etc. I do this, because even I (who understands why captchas are a must) will leave a low traffic site, if it requires a typed captcha to comment, or join.
  8. This section: if($_SERVER['REQUEST_METHOD'] == 'POST'){ die(header("Location: $baseurl/slorg/upload.php?error=Please+do+not+leave+any+info+blank."));} Reads: If POST data has been send, redirect to upload?error=Please+do+not+leave+any+info+blank, then exit the script. I'm not sure that is what you want (I know it isn't). Doing this responded in Please do not leave any info blank. The quoted section, and the section that gives this error, isn't related to each other.
  9. Most likely it is because the 'eregi' function is depreciated. Try changing: if (!eregi("image/", $_FILES['Image']['type'])) { to: if(substr($_FILES['Image']['type'],0,5) == 'image' ) {
  10. Try this: <?php //syntax highlighting $startingRBsbefore = array(); foreach($startersrosterbefore as $ID => $row) { if($row['positionid'] == 2) { $startingRBsbefore[] = $row; } } foreach($startingRBsbefore as $value) { echo implode('<br />',$value); } Don't know why it is only returning the last one, as the code in the OP should work. IF each players id is unique.
  11. So, post what code that you have. Yes, you can make it work all on one page, but we cannot point you in the right direction, if we don't see what you already have. Make sure you wrap your code in the code blocks, its the # button. Cheers, JC
  12. The mysqli object handles all escaping internally. Being that you are passing the salt as a string, it will pass the variable (by reference) through the mysqli::real_escape_string() function.
  13. What does this give you? $option_price = 0; foreach ($product_option_prices as $product_option_price) { $option_price += $product_option_price['option_price']; } You could even type cast to (float).
  14. Sometimes a picture is worth a thousand words. So, I dug way back in the library, and dusted off a very old function that I had. It was tucked way back there, in amongst some crumpled paper. <?php //include connection info. include('config.php'); //point to file that holds database connection info. //function to show all results from a table. function browseData($tbl) { //declare function, argument says to pass the function the table name. $result = mysql_query("SELECT * FROM `$tbl`"); //get the resource. $output = NULL; //start the output variable. $output .= mysql_num_rows($result) . " Results!"; //show rows returned. $c = mysql_num_fields($result); //get a count of the fields. $output .= "<table class=\"search\">"; //start a table. for ($i=0; $i < $c; $i++) { //for( start i at 0, if i is less than fields count then continue, incrementing i as it continues) $output .= '<th style="background-color:blue;">'.ucwords(mysql_field_name($result, $i)).'</th>'; //print a table header for each field name. } $d = 1; //yep, I made useless variables too, long ago. Ah, closer look it is for the background alteration of colors. while($r = mysql_fetch_array($result)) { //fetch the array, should either be row, or assoc (in this case row). $output .= '<tr style="background-color:'; //new table row for each row of data. $output .= (($d % 2) == 0) ? '#ACCDE2;' : '#0088E2;' ; //alternate background color for each row. $output .= '">'; //closing the tr element. $i = 0; //start a new $i variable. while($i < $c) { //while i is less than c (field count). $output .= "<td>" . $r[$i] . "</td>"; //print a td element with the contents of the data row/column. $i++; //increment i } $output .= "</tr>"; //close row. $d++; //increment d (who knows). } $output .= "</table><br/><br/>"; //close table, adding spacing. return $output; //return the function contents. } //call the function, and print the results to the page. $db_table = 'test'; //Your table name. echo browseData($db_table); //echoing a function will print the return of that function. (in this case $output) ?> I commented this function, and even left in those things that I used to do that are not the best coding practices. Although, I told how to fix them in the comments.
  15. Ujj, if I could offer another suggestion. In the future, store you dates as a DATETIME or TIMESTAMP column type. This is because MySQL has VAST amounts of functions just for dates, and times. Which would make reports a breeze to produce.
  16. Ujj, in an effort to understand why we are suggesting to restructure your database, please take the time to watch and understand . IMHO, databases should extend to at least the 3rd Normal Form.
  17. Ah Pik, the `ole "stop trying to help me, but give me what I want" thread. You never win in this one. Back to the OP, the request you posted, has nothing to do with the code you posted. <?php session_start(); if(isset($_GET['name'])) { $name = $_GET['name']; $_SESSION['name'] = $_GET['name']; } elseif(isset($_SESSION['name'])) { $name = $_SESSION['name']; } else { $name = 'Guest'; } echo 'Welcome ' . $name;
  18. You need to find out why: $u_id = mysql_real_escape_string($_SESSION['id']); $u_name = mysql_real_escape_string($_SESSION['username']); $u_email = mysql_real_escape_string($_SESSION['useremail']); $u_loca = mysql_real_escape_string($_SESSION['userloca']); $sql = mysql_query("SELECT * FROM myMembers WHERE id='$u_id' AND username='$u_name' AND email='$u_email' AND locator='$u_loca'"); $numRows = mysql_num_rows($sql); if ($numRows < 1) { echo "ERROR: You do not exist in the system."; exit(); } This database query doesn't work. Try looking at your session variables, and finding why they do not match what is in the database. echo '<pre>' . print_r($_SESSION,true) . '</pre>'; Additionally, please put your code inside of the [ code ] ... [ /code ] blocks provided, they make reading it much easier.
  19. Do you wish to get the parsed content from server A, to use on server B? Just call the file with a file_get_contents. If you wish to send variables to server A from server B, and have the file parse them, you will have to send those variables via POST, or GET.
  20. Sorry, I was under the impression that multiple invitations were to be printed. I changed a line or two that should satisfy your interest, although, the code is merely an example. <?php //syntax highlighting while($row = mysql_fetch_row($result)) { //while rows exist in the database. $names[] = $row[4]; //store names in an array. *CHANGED looks like you had 4 and 1 reversed from what you gave. $links[] = '<a href="' . $row[1] . '">' . $row[4] . '</a>'; //store facebook links in an array. *CHANGED looks like you had 4 and 1 reversed from what you gave. } foreach($names as $name) { //loop through the names, and write them a letter. //heredoc syntax. echo <<<EOF Dear {$name},<br /> Please join me this friday at 6pm.<br /> Total quest list: <br /> EOF; echo implode('<br />',$links); //implode all the links with a pipe in between each one. *CHANGED the pipe to a break rule* echo '<hr />'; //*ADDED a horizontal rule. FOR DISPLAY PURPOSES. }
  21. Yes, I agree with jazzman, use heredoc syntax, or break out of PHP and use straight HTML since there are no variables in there. The reason why you get that error, is you started the string with a double quote ("), so the next time PHP sees another double quote, it thinks you are ending your string. Other than changing to heredoc, or nowdoc, you can start the string with a single quote ('), or escape the double quotes like (\"). Valid: <?php //syntax highlighting $form = "<form method=\"post\" action=\"signup-p.php\" id=\"signupform\">"; //will populate variable inside the string. //or $form = '<form method="post" action="signup-p.php" id="signupform">'; //will not populate variables in the string. //or //will populate variables in the string. $form = <<<string <form method="post" action="signup-p.php" id="signupform"> string; //or //will not populate variables in the string. $form = <<<'string' <form method="post" action="signup-p.php" id="signupform"> string;
  22. No need for 2 while loops. Store everything in array's, that way you have a complete list of everyone's facebook links. Then go through the 1st array making invitations, then implode the facebook links to the bottom. <?php //syntax highlighting while($row = mysql_fetch_row($result)) { //while rows exist in the database. $names[] = $row[1]; //store names in an array. $links[] = '<a href="' . $row[4] . '">' . $row[1] . '</a>'; //store facebook links in an array. } foreach($names as $name) { //loop through the names, and write them a letter. //heredoc syntax. echo <<<EOF Dear {$name},<br /> Please join me this friday at 6pm.<br /> Total quest list: <br /> EOF; echo implode('|',$links); //implode all the links with a pipe in between each one. }
  23. Or, you could do it with systems that are already available. Like Fusion Charts Free
  24. Why did you change the information given? $app_application is not what Pik wanted you to test for.
×
×
  • 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.