Jump to content

Shocker88

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Everything posted by Shocker88

  1. Check that the queries that those mysql_num_rows are calling (ie. $check1 and $result) are actually returning a query and not erroring (shouldn't be the case). I assume the issue might be in the syntax of your if statements. set a variable for the number of rows returned first then put that in the if statement: $check1 = mysql_query("SELECT vote FROM actors WHERE `actor`='{$actor}' "); $check1_rows = mysql_num_rows($check1); if($check1_rows > 0) { }
  2. You'll have to provide a bit more info - what kind of problem are you running into? (I'm assuming the mysql_connect values you have are actually variables that you've replaced? Or is that a direct copy from what you have on your server?) I've slightly changed some of the code since the snippet you posted was a little dirty - try this though it probably won't fix an issue just clean up the code <?php $user="root"; echo "Currently "; $connect=mysql_connect("localhost","dbuser","dbpass") or die("Could not connect"); mysql_select_db("dbmembers") or die("Could not find database"); $query = "SELECT * FROM users ORDER BY name DESC LIMIT 20"; $res = mysql_query($query) or die("Couldn't execute query: ".mysql_error()); $numrows = mysql_num_rows($query); echo $numrows . "registered users."; while ($user = mysql_fetch_assoc($res)) { echo $user['username']; echo $user['date'] . "<br />"; } ?>
  3. The issue is the action of the form - that script checks in itself if the form has been submitted and returns the story if it has. therefore change <form method = "post" action = "Story.php"> to: <form method = "post" action = ""> This will reload the same page, and now that isset($_POST['submit'])) returns true (since the form has been submitted) it will display the story back to the user. EDIT: beaten to the punch - I'll leave it up as it may help explain a little better
  4. You'll want to give us an error to look at where the problem is occuring - don't think many forum goers want to check your syntax for a missing bracket etc.. As thorpe said try using firebug, the plug-in for firefox. Are you sure it is connecting to the database correctly? If you have mysql errors off, it could be an issue. Anyway, anymore information you can provide will help you get an answer a lot. Debug/break it down and try work out what is working in the script and what is not.
  5. As pbs said above, best to do this validation in javascript (using a library such as jQuery may help). The only thing you'd really want to check server-side (in the php) in a simple contact form such as that, is whether the required fields are filled in. ie. if you wanted to make sure they entered a name in: if ($_POST['username'] == '') { echo 'Please make sure you enter a username before submitting the form.'; } else { // process results } You could get more specific on which values they can enter in what field but that would require regex which is far more complex if you are new to validation.
  6. Very vague, you'll have to explain a bit more. So you have an iframe on your page that you want to show the contents of an external site within, but for some reason the iframe is just showing your own web sites information within it? Seems odd..as that should be easily avoided by ensuring you are linking to the right URL when you create the iframe (which is also not a php issue..) Can you clarify what you're asking so I can help some more mate?
  7. Hey mate, You're a big vague here...You want to go to numerous links within the same PHP script? If you want each link to essentially step through the pages with more links you could setup a form and use isset() to to work out which information (link) in the PHP script to show. Is that what you're looking for??
  8. Not quite sure what you mean here? So essentially it looks like you want to assign a specific URL if the URL that is posted by the user/author links to rapidshare and megaupload? If so you could use preg_match_all() as you have for the images, however I'd probably just use strpos() to check if the URL string inputted by the user includes megaupload or rapidshare.... If you need help with the code I can but just need clarification that is what you require?
  9. Did implementing the suggested statement fix your problem mate?
  10. So i'm trying to setup a cron file and being a cron newbie (php/sql as well), I don't know what is needed to update each users account individually. ie. It takes the first user in the databases values and transfers them down to all users regardless of what values they should have. The script sets back most variables to 0, but it gives back users $hitpoints = to their $maxhp, $energy = to their $energymax and gives $10 000 cash when exectuted. However instead of doing this individually coz each users, it determines the value for the first user in the database and sets that as the variable for all other users. <?php include('conf.php'); //Connection to SQL $connection = @mysql_connect($host, $user, $pass) or die ('Unable to connect!'); mysql_select_db($db); $username = $_SESSION['username']; // Arrays list $query = "SELECT * FROM users"; $result = mysql_query($query); $array = mysql_fetch_array($result); //Set hitpoints and cash values. $hitpoints = $array['maxhp']; $cash = $array['cash'] + 10000; //Save to DB. $query = "UPDATE users SET hitpoints = '$hitpoints', cash = '$cash'"; $result = mysql_query($query); // Gym Arrays $query1 = "SELECT * FROM gym"; $result1 = mysql_query($query1); $array1 = mysql_fetch_array($result1); $energy = $array1['energymax']; $warmcount = 0; $energyused = 0; $totalwarm = 0; $totalmodgym = 0; $query = "UPDATE gym SET energy = '$energy', warmcount = '$warmcount', energyused = '$energyused', totalwarm = '$totalwarm', totalmodgym = '$totalmodgym'"; $result = mysql_query($query); ?> Any help would be much appreciated, thanks.
  11. Gosh..needed double ='s to assign the same value...transfering knowlegde from other languages can be a killer on syntax. Thanks for the reply - made me look at it differently and revealed the error heh.
  12. Hey, just having some trouble with the variables $agility and $eagility losing their set initial values (in this case 5 and 8 respectively) when in the following code: $agility = $ag1; $eagility = $ag2; while ($hitpoints >= 1 and $ehitpoints >= 1) { if ($agility >= $eagility) { $ehitpoints = $ehitpoints - $strength; echo $ehitpoints . " you <br>"; $eagility = $eagility + $ag2; } else { $hitpoints = $hitpoints - $estrength; echo $hitpoints . " enemy <br>"; $agility = $agility + $ag1; } } the $ag1 and $ag2 variables seem to have the same problem, however $hitpoints, $ehitpoints and $estrength seem to be holding the correct values...Any help on this matter would be much appreciated! Thanks in advance. EDIT: To clarify this the values seem to be set to either 0 or null when called, both before and after the line that should edit the value (ie. $agility = $agility + $ag1;).
  13. Nah - wasn't the attack.php script. session_start() is called in the template which is included at the top. Anyway thanks for the help should have posted earlier instead of beating my head against the wall because im too tired to think.
  14. Thanks lol - this is why I should have stopped coding a while ago 3:30am is a bit late to be trying anything..time to head to bed Thanks heaps.
  15. Hey having some trouble setting a session from the result of this drop down box when submitted.. <?php //includes include('template1.php'); $query = "SELECT enemyname, enemyid FROM enemies ORDER BY enemyid asc"; $result = mysql_query($query); echo "<form method='post' action='attack.php'> <select name='enemies' value='enemies' id='enemies'>"; while($row = mysql_fetch_array($result)) { $r0 = $row[0]; $r1 = $row[1]; echo "<option value='$r1'>$r0</option>"; } echo "</select> <input type='submit' value='Attack' name='Attack'> </form><br>"; $_SESSION['enemies'] = $_POST['enemies']; include('template2.php'); ?> Everything seems to be working fine except for some reason the session is not setting to the value posted via the drop down.
×
×
  • 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.