Jump to content

Spike121

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Spike121's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. What's the "LIMIT 2" for? Also, is there anything (besides "tablename") I have to edit, because I'm getting "Resource id #13" as a result.
  2. Okay, I know I already posted this in MySQL help, but there's no active users there, so I'm posting it here. I need a MySQL code that selects a random result from a table. select link from table1 Would that select a random one, or the latest entry? If it wouldn't select a random result, what would? Also, what would select the latest one too? I need both if possible. Thanks in advance!
  3. Hey, I'll jump right into it. I need a MySQL code that selects a random result from a table. select link from table1 Would that select a random one, or the latest entry? If it wouldn't select a random result, what would? Also, what would select the latest one too? I need both if possible. Thanks in advance!
  4. Don't forget to put [ code ] before and [ /code ] after your code please (without the spaces). From what I could see, this should work. You forgot the php after ? <?php $db_connect = mysql_connect("localhost","username","password"); mysql_select_db("cs",$db_connect); $table = "statusValues"; if(isset($function) && $function == "add") { echo "This is the value - $regionNumber<br>"; $sql_query = "insert into statusvalues (firstname,lastname,region,ssn) values ('".$fname."','".$lname."','".$regionNumber."','".$ssn."')"; $exe_query = mysql_query($sql_query); } $sql_reg = "select * from region"; $sqlQuery = mysql_query($sql_reg); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> </head> <body> <form name="form1" method="post" action="indexxx.php?function=add"> <p>First Name: <input type="text" name="fname" id="fname"> </p> <p>Last Name: <input type="text" name="lname" id="lname"> </p> <p>Select Region Number: <?php echo "<select name='regionNumber' id='regionNumber'>"; while($record = mysql_fetch_array($sqlQuery)) { echo "<option value = '".$record['regionNumber']."'>".$record['regionNumber']."-".$record['regionName']."</option>"; } echo "</select>"; ?> </p> <p>Enter SSN No Dashes: <input type="text" name="ssn" id="ssn" /> </p> <p> <input type="submit" name="button" id="button" value="OK" /> </p> </form> <?php // Edited here. Don't forget the "php" after the question mark. $selectQuery = "select * from statusvalues order by lastname ASC"; $resultName = mysql_query($selectQuery);// or die(mysql_error()); echo "<table width='400' border='1' cellspacing='0' cellpadding='0'> <tr> <td>ID</td> <td>First Name</td> <td>Last Name</td> <td>Region</td> </tr>"; while($myRowRes = mysql_fetch_array($resultName)) { echo "<tr> <td>".$myRowRes["statVal_id"]."</td> <td>".$myRowRes["firstname"]."</td> <td>".$myRowRes["lastname"]."</td> <td>".$myRowRes["region"]."</td> </tr>"; } echo "</table>"; ?> </body> </html>
  5. I got this error once, I can't remember how I fixed it. Is your coloumn name "CustomerID" or "customerID" because it is case sensitive.
  6. Perfect, works good. However, I don't quite understand that last line, echo (test_url_file($url)) == 1 ? "Connected" : "Not Connected"; That's obviously where it's returning the words if it's connected or not, but what if I want it to display a huge amount of code, instead of one or two words? Would I just do... <?php $url = "http://google.com"; function test_url_file($url) { $res = (($ftest = @fopen($url, 'r')) === false) ? false : @fclose($ftest); return ($res == TRUE) ? 1:0; } echo (test_url_file($url)) == 1 ? " ?> // End PHP here to write lots of lines of code //This is //lots of //lines of code <?php " : "?> //more code // // <?php "; ?>
  7. Now it shows everything as "WRONG". Should I change it to else if ($res == 0) { echo "WRONG"; } Edit: Wait, that wouldn't matter. I'm trying it with all variations of google.com. http://google.com. http://www.google.com. www.google.com. None work.
  8. Okay, so I tried this... <?php $url = "http://www.google.com"; function test_url_file($url) { $res = (($ftest = @fopen($url, ‘r’)) === false) ? false : @fclose($ftest); return ($res == TRUE) ? 1:0 ; } if ($res = 1) { echo "Connected."; } else { echo "WRONG."; } ?> And the page returned "Connected.", and I was happy. So I tried a different one, obviously not a website (I typed in random words, with spaces, which is impossible for a website to have), and it still said connected. I'm not sure if I did it right, I'm not very good with functions yet, or ftests (which I think are socket tests but I'm probably wrong, still learning). Any ideas? Should I try the other method on that page?
  9. Hmm, does look promising. Guess you need to know what to search . I was looking for about half an hour. Thank you! I'll test it now.
  10. Okay, so I know this should be possible, and I haven't tried it yet, but I don't know. What I want to do is let a user enter a website link, then I want the code to try to connect to the website, to see if it's real. I know it's possible if you're using the actually IP addresses of websites, but I don't know if I need the IP addresses, or if somehow the code can find them, and then check? Appreciate the help I will update the post if/when I can find my old code of check the IP addresses Edit: Okay, so I've found this: @fsockopen($serverip, $serverport, &$errno, &$errstr, 10) Not sure if it will work, I'll test it now. However, what port would be used? I remember FTP port is 21 or 22, but I doubt it would be those ports. Maybe port 80?
  11. Permissions on a FTP file are not actually PHP, but what you need to do (I think) is to use a FTP program such as FileZilla (downloaded free, you can google it), then connect to your FTP server, and right click the folder the files are being uploaded to (in this case, I think it's the customers folder?), and then click Permissions or something along the lines of that. Then set the permissions to 777, or tick all boxes. That should work.
  12. I prefer codes I can understand, theres some of that new code I don't get. Plus, I'd have to change it to do while, because the while one seems to skip the first entry in my database for some reason, I don't know why.
×
×
  • 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.