Jump to content

mikesta707

Staff Alumni
  • Posts

    2,965
  • Joined

  • Last visited

Everything posted by mikesta707

  1. ok, but in that particular script, after you switch to the discover database, what do you do once switched? by the way you aren't switching to a discover table, you are switching databases. IDK if this has something to do with it, or if you are confusing databases and tables
  2. which line is line 38?
  3. change <td class=align_levels>$sub_attributes_points</td> to <td class=align_levels><?php echo ($sub_attributes_points == 0) ? "" : $sub_attributes_points; ?></td>
  4. thats because there is a : after http. $lines = file('path/to/file.txt'); $urls = array(); foreach ($lines as $line) { list($user, $pass, $http, $url) = explode(':', $line); $urls[] = http.":".$url; } should work
  5. the unexpected end is probably from your closing bracket being connected to your opening php tag. Well when I copied and pasted your code to my server it didn't work until I created a space. this did not work: If(isset($df)){?><a href="contactus.php">Contact Us</a> |<?php} this did If(isset($df)){ ?><a href="contactus.php">Contact Us</a> |<?php }
  6. well why exactly do you switch to that database? I don't see any queries afterwards so try just removing that line.
  7. and you get no errors? it just echos the script? Thats one of the strangest problems i've ever seen on these forums... I just tested some code very similar to yours and it works... maybe there is a problem with your server
  8. hmm... yeah since you basically do the same thing in the script that works, it should work perfectly fine in the non-working script. The user account you are using has the necessary privileges right?
  9. $html = "code blah blah blah include(\"html2.php\") goes here"; just write include() inside the string. Don't concatenate it, b/c it will execute then, and won't execute when the code is output, or echo'd. Hope that helps!
  10. well, firstly thats not how a do while loops goes. A do while loop does the action, than checks if the while boolean statement is true. If it is, it does it again, until the statement isn't true. but you can;t really put a do inside a while like you did there. it should look something like $cookies = 0; do { echo "Mmmmm...I love cookies! *munch munch munch*"; } while ($cookies > 1); Output: Mmmmm...I love cookies! *munch munch munch if you noticed, even though the while boolean statement was false, the "do" code block executed. Thats because the do block was executed, then the while statement was checked. it turned false, so the do code block wasn't executed again. check out this tutorial for more information on that : http://www.tizag.com/phpT/dowhile.php as far as the rest of your code, i'm afraid its mostly wrong too. When you write an if statement, you need a boolean statement next to it, like if (some boolean statement){ //do this } else { //do something else } So with your code, you want to make it look like while(while($r=mysql_fetch_array($result)){ if ($status == '1'){ continue; } else { //next product code } } im assuming you already know how continue works so besides the syntax errors, your code's logic is about right EDIT: Oh ok. make sure to mark to topic as solved!
  11. thats interesting... it may be because your php tags and your closing brackets don't have a space between them. try adding a spce between <?php and }
  12. if ($row['status'] == 1){//assuming that its a numeric 1, not a string with the value of '1' //output whatever } something like that? You could stick that in your while loop like: while($r=mysql_fetch_array($result)) { //the format is $variable = $r["nameofmysqlcolumn"]; //modify these to match your mysql table columns $id=$r["prod_id"]; $upc=$r["prod_code"]; $name=$r["prod_name"]; $price=$r["prod_price"]; $size=$r["prod_weight"]; if ($r['status'] == 1){ echo "<tr> <td>$id</td> <td>$upc</td> <td>$name</td> <td>$price</td> <td>$size</td>"; echo "</tr>"; } }
  13. the login credentials for the discover_discover database may be different than the credentials for the other database.
  14. of course! that is the beauty of programming. Ill give an example for sake of ease, im going to leave out the connect and db select statements, and just show the function function makeTable($sql){ $query = mysql_query($sql) or die("ERROR" . mysql_error()); //lets make the header, and the first row $row = mysql_fetch_assoc($query); echo "<table border='1'>"; echo "<tr>"; //this will create the headers by looping through the array //and echoing the array's indices foreach($row as $key=>$value){ echo "<td>$key</td>";//you could also use <th> or table header tags } echo "</tr>"; //end the header row //now make the first row echo "<tr>"; foreach($row as $value){ echo "<td>$value</td>"; } echo "</tr>";//end first row //now lets go through the rest of the rows while ($row = mysql_fetch_assoc($query)){ echo "<tr>";//start row foreach($row as $value){ echo "<td>$value</td>"; } echo "</tr>";//end row }//end while }//end function if you were to call the function like so makeTable("select * from TABLENAME"); the output should be the same as the code posted by me or rhode. There may be a syntax error or two, but the basic logic is still there hope that helps!
  15. are you getting any mysql errors? I still don't really understand what your problem is. What is supposed to happen and what is actually happening?
  16. well first off, that doesn't even close the table tag. but if you wanted to create a table with all the information do something like this //create the table head echo "<table border='1'>" echo "<tr><td>prod_id</td>"; echo "<td>prod_code</td>"; #etc etc echo "</tr>"; //get sql and loop through it //connect to mysql //change user and password to your mySQL name and password mysql_connect("localhost","USERNAME","PASSWORD"); //select which database you want to edit mysql_select_db("DBNAME"); //select the table $result = mysql_query("select * from TABLENAME"); //grab all the content while($r=mysql_fetch_array($result)) { //the format is $variable = $r["nameofmysqlcolumn"]; //modify these to match your mysql table columns $id=$r["prod_id"]; $upc=$r["prod_code"]; $name=$r["prod_name"]; $price=$r["prod_price"]; $size=$r["prod_weight"]; echo "<tr> <td>$id</td> <td>$upc</td> <td>$name</td> <td>$price</td> <td>$size</td>"; echo "</tr>"; } that will create a table, but of course this script can only be used for that specific query, and it won't work with any other queries
  17. well which variable is for price? is it $price[1]? none of that math adds anything to that variable... where is it deducted? idk whats going on in your code, but this problem seems pretty easy to fix
  18. the strstr and stristr function sound like they could do what you want. These functions find the first occurence of a string (your search) inside another string (your html document) strstr is case sensitive while stristr is case insensitive. http://www.w3schools.com/PHP/func_string_stristr.asp (stristr) beyond that, you should probably look into regex of some kind
  19. queries as in mysql or other database queries I would presume. What errors come up?
  20. I don't know what you mean by "remain linked" but to get two columns from a table, and store them into an array you can do something like $sql = "SELECT col1, col2 from table where something=something_else"; $query = mysql_query($sql); $row = mysql_fetch_assoc($query); echo $row['col1'] . "<br />; echo $row['col2'] . "<br />; that would output the two columns from the first row your query returned. to go through all the rows your query returns you can do something like $sql = "SELECT col1, col2 from table where something=something_else"; $query = mysql_query($sql); while($row = mysql_fetch_assoc($query)){ echo $row['col1'] . "<br />; echo $row['col2'] . "<br />; } you can also use the mysql_fetch_array function: http://us2.php.net/manual/en/function.mysql-fetch-array.php here is the page about mysql_fetch_assoc: http://us2.php.net/manual/en/function.mysql-fetch-assoc.php and another function, that returns an array with only number indices: http://us2.php.net/manual/en/function.mysql-fetch-row.php Hope that helps
  21. you have to MD5 the posted password also. A normal password will never equal its MD5'ed counter part so $gUser = mysql_query("SELECT * FROM test WHERE username='".$username."' AND password='".md5($password)."' LIMIT 1") or die(mysql_error()); should fix your problem EDIT: dam ignace beat me to the punch
  22. die will exit the script before the header is executed
  23. um.. no that is a horrible idea... I would use a regex expression. someone here could probably give you a better example than I could, but a regex expression could be used to do exactly what you need.
  24. its probably your associative array keys, as Maq has said. You probably have a mysql query error. Try doing or die("ERROR: " . mysql_error()); after your query, and surround your associative array keys with single quotes
  25. Ahh I see. I forget the single quotes alot . Make sure to mark the topic is solved!
×
×
  • 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.