Jump to content

jasonxxx102

New Members
  • Posts

    9
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

jasonxxx102's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, so I have a full page iFrame with wikipedia as the URL and I want to know how I can make it so that when the user clicks a link they cant go back a page.
  2. Thanks mac_gyver! your help was much appreciated
  3. Ok, so I have a main page that grabs data from a MySQL db and posts it into a dropdown menu see here: $sql = "SELECT * FROM 4000Series"; $result = $con->query($sql); print "Select your GPU: <select name='gpuId'>"; while ($row = $result->fetch_assoc()) { print "<option value='" .$row["id"] . "'>" . $row["gpu"] . "</option>"; } print "</select> </br>\n"; This works fine, from here I'm passing the POST data from the option values to a new page (basically the option values correspond directly to the "id" value in my SQL db). The values are passed onto the new page fine, but when I try to setup an SQL select statement to grab the row with the corresponding "id" value and print it out with a while loop I'm shooting a blank. Here's the code for the second page $id = $_POST['gpuId']; **Connect to sql db here** $sql = "SELECT * FROM 4000Series WHERE $id ='id'"; $result = $con->query($sql); echo "<table>"; while ($row = $result->fetch_assoc()){ echo "<tr><td>" . $row['id'] . "</td><td>" . $row['gpu'] . "</td></tr>"; } echo "</table>"; When I view the source it prints out the table tags but nothing in the while loop, any ideas?
  4. Thanks! I switched over to mysqli and changed up my code slightly and now I can display the values in my row. Can anyone explain to me why each value has 2 entries in the array though? The page displays this now: Array ( [0] => 1 [id] => 1 [1] => 4350 [gpu] => 4350 [2] => 10.000000 [khs] => 10.000000 [3] => 100.000000 [usd] => 100.000000 [4] => 20.000000 [watts] => 20.000000 [5] => 0.100000 [khd] => 0.100000 [6] => 0.500000 [khw] => 0.500000 [7] => 0.003000 [ltcday] => 0.003000 [8] => 0.010000 [usdday] => 0.010000 [9] => 9823.000000 [payoff] => 9823.000000 ) Sorry if these questions are very basic I'm very new to PHP. Thanks again for the help!
  5. Ok, so I created a test database on my server, created 1 table with 1 row in it and the row is populated with values. I can connect to the database without error, but when I try to put in a while loop to print the results I get nothing but a blank screen. I tried placing some debug code in the while loop to see where its getting hung up but the while loop doesn't want to run at all. I placed an echo directly outside of the loop and the debug text is displayed fine but anything I put in the loop doesn't work. Can anyone help me out? Here is my code: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php $dbuser = "webestat_testdb"; $dbpass = "password"; $dbname = "webestat_testdb"; $server = "localhost"; $conn = mysql_connect($server, $dbuser, $dbpass); if (!$conn) { echo "Failed to connect to db" . mysql_error(); } $selectdb = mysql_select_db('webestat_testdb', $conn); $sql = "SELECT * FROM 4000Series"; $results = mysql_query($conn, $sql); while($row = mysql_fetch_assoc($results)) { echo "test"; echo $row['gpu']. " " .$row['khs']. " " .$row['usd']; echo "<br>"; } mysql_close($conn); ?> </body> </html>
  6. Did I ask for somebody to write the code for me? I asked for somebody to point me in the right direction. If you're not going to be constructive just save your time and don't post.
  7. I have a basic PHP web crawler script and I need to expand its functionality, the problem is I'm a total noob at PHP and my knowledge is very basic so I'm coming here for some help. My goal is to have a basic user input (text box) and when the user types in a phrase; let's say "Red Apples" and hits the enter button the script should start crawling the web for the phrase "Red Apples" and store the plain text results along with the URL they originated from in a database. Here is what I've got so far: error_reporting( E_ERROR ); define( "CRAWL_LIMIT_PER_DOMAIN", 50 ); $domains = array(); $urls = array(); function crawl( $url ) { global $domains, $urls; echo "Crawling $url... "; $parse = parse_url( $url ); $domains[ $parse['host'] ]++; $urls[] = $url; $content = file_get_contents( $url ); if ( $content === FALSE ) { echo "Error.\n"; return; } $content = stristr( $content, "body" ); preg_match_all( '/http:\/\/[^ "\']+/', $content, $matches ); echo 'Found ' . count( $matches[0] ) . " urls.\n"; foreach( $matches[0] as $crawled_url ) { $parse = parse_url( $crawled_url ); if ( count( $domains[ $parse['host'] ] ) < CRAWL_LIMIT_PER_DOMAIN && !in_array( $crawled_url, $urls ) ) { sleep( 1 ); crawl( $crawled_url ); } } } If anybody could point me in the right direction that would be awesome.
  8. Yep, everything is correct I've checked it a few times. That's why I'm so confused
  9. So, I was transferring an SQL database to another website today and I did everything the way I should have but the site keeps giving me a weird error. I have MySQL version 5.1.56 Database error: Invalid SQL: SELECT id FROM stats WHERE date='20/05/11' MySQL Error: 1146 (Table 'webestat_site.stats' doesn't exist) Session halted. It is telling me the table doesn't exist but I checked in the SQL database and the table is there. If anybody could help me that would be great.
×
×
  • 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.