Jump to content

hemlata

Members
  • Posts

    40
  • Joined

  • Last visited

    Never

Everything posted by hemlata

  1. Hello, This kind of error usually comes if no database connection is established. In your code to i didnot saw the db connection code. Try to add following code before 'mysql_select_db' command and see if you get your problem solved.. $jonathan = mysql_connect($hostname, $username, $password); Regards,
  2. Hello, Have you run your query on mysql? Is it returning results? Regards,
  3. Hello, You can write the update query in the while loop. Take an example given below. while($row = @mysql_fetch_array($result)) { $addy = substr(strrchr($row['address'],">"),1,4); $query = mysql_query("UPDATE `content` SET `address` = '".$addy."' WHERE `address` = '".$row['address']."'") or die(mysql_error()); } Hope this could solve your issue. Regards,
  4. Hello, Apart from printing variables $_POST and $_FILES, also check whether you have included ENCTYPE="multipart/form-data" in your form or not... Hope this might solve your issue. Regards,
  5. Hello, Modify your code.. if($_POST[op] !="send"){ To .. if(!isset($_POST['submit'])){ and }else if ($_POST[op] == "send"){ to.. }else{ Hope this will solve your issue. Regards,
  6. Hello, Modify your script with the following code block, may be either you get your problem solved or the result will return the error for the query.. $query1="SELECT * FROM `profile_blog` WHERE `id` = '" . $_GET['id'] . "'"; $result=mysql_query($query1) or die(mysql_error()); $data=mysql_fetch_array($result); Regards,
  7. Hello, Yes, i think it can be done. i tried a simple script on two tables and it run successfully UPDATE table1 AS t1, table2 AS t2 SET t1.field1 = 'test1', t2.field2 = 'test2'; Regards,
  8. Hello, If you know the 'key' for the multidimensional array then you can directly get the value as.. Eg. $array['key1']; Hope this might solve your issue. Regards,
  9. Hello, Again a small spelling mistake... Print the $_POST variable inside if and see the output. You have spelled '[training] => agility' to '[training] => agilty'. Missing with 'i'. Hope now you will get the required results. Regards,
  10. Hello, What is the value of $target you are getting. Since the following code is running successfully on my end.. <?php // new name for the uploaded file test.jpg $name = 'test1.jpg'; $target = "uploads/"; $target = $target . $name; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file was uploaded"; } else { echo "Problem during upload"; } ?> Regards,
  11. Hello, I too agree with thorpe for giving logical indentation though it is code of 20 lines or less. See because of 'not having logical indentation' in your code, you were not able to find the problem in your posted code. Here you were having two additional closings after case 'weights' . Check the modified code and see if you could have your problem solved. <?php print "<form method=post action=intrain.php?view=train&step=trainingturns>Use<input name=amount>Energy Training On <select name=training><option value=weights>Weights</option><option value=agility>Tredmill</option></select>. <input type=submit value=Buy></form>"; if (isset($_POST)) { switch($_POST['training']) { case "weights": if ($stat[energy] < $amount) { print "<br>Your going to need $amount to train that hard."; } elseif ($stat[hp] < 1.0) { print "<br>You cant train unless you are alive you loser."; } else { $chance = rand(1,10); $chance13 = rand(1,2) / 700 / $stat[level] * $amount; $chance14 = rand(3,5) / 700 / $stat[level] * $amount; if ($chance == 1) { print "<center>Man you were so bad in the gym<bR> you got kicked out for slacking<br>next time actually do some weights."; mysql_query("update players set energy=energy-$amount where id=$stat[id]"); } else { print " <center>Hey $stat[user] i never knew you were that fast!<br> you should come here more often if you want to stay in that condition<bR>You gained $chance14 strength<br>and $chance13 agility<br> <a href=intrain.php?action=tredmill>Run Again</a><bR><br> "; mysql_query("update players set strength=strength+$chance14 where id=$stat[id]"); mysql_query("update players set agility=agility+$chance13 where id=$stat[id]"); mysql_query("update players set energy=energy-$amount where id=$stat[id]"); } } //} ADDITIONAL CLOSING //}ADDITIONAL CLOSING break; case "agilty": if ($stat[energy] < $amount) { print "<br>Your going to need $amount to train that hard."; } elseif ($stat[hp] < 1.0) { print "<br>You cant train unless you are alive you loser."; } else { $chance = rand(1,10); $chance13 = rand(1,2) / 700 / $stat[level] * $amount; $chance14 = rand(3,5) / 700 / $stat[level] * $amount; if ($chance == 1) { print "<center>Man you were so bad in the gym<bR> you got kicked out for slacking<br>next time actually do some weights."; mysql_query("update players set energy=energy-$amount where id=$stat[id]"); } else { print " <center>Hey $stat[user] i never knew you were that fast!<br> you should come here more often if you want to stay in that condition<bR>You gained $chance14 strength<br>and $chance13 agility<br> <a href=intrain.php?action=tredmill>Run Again</a><bR><br> "; mysql_query("update players set strength=strength+$chance13 where id=$stat[id]"); mysql_query("update players set agility=agility+$chance14 where id=$stat[id]"); mysql_query("update players set energy=energy-$amount where id=$stat[id]"); } } } } ?> Regards,
  12. Hello, In 'read_news.php', instead of echoing id, get the related record for this id from the database and display that. So.. modify the code as per the comments below... <?php $id= &$_REQUEST['id']; if (isset($id) && $id!='body') { // connect to the DB // Get the records from table 'newsdb' where id = $id // display 'news_details' } else { include "body.php"; } ?> Hope this will solve your issue. Regards,
  13. Hello, There are 2 mistakes in your code block - First of missing ';' (Also pointed by rarebit) - And another one of not using quotes while comparing string in if-elseif conditions. Modify your code with the following code block if ($exercise == '0 Hours') { $fit1 == 0; } elseif ($exercise == '1 Hours') { $fit1 == 1; } elseif ($exercise == '2 Hours') { $fit1 == 2; } elseif ($exercise == '3 Hours') { $fit1 == 3; } elseif ($exercise == '4 Hours') { $fit1 == 4; } else { $fit1 == 5; } Hope this will solve your issue. Regards
  14. Hello, Modify your code with following code block to get the required results. <?php $tempPath = "img/"; if ($handle = opendir($tempPath)) { while (false !== ($file1 = readdir($handle))) { if ($file1 != "." && $file1 != "..") { if(is_dir($tempPath."/".$file1)) { echo $file1 . '<br>'; } } } closedir($handle); } ?> Hope this will solve your issues. Regards,
  15. Hello, Replace your code print "<tr><td>"; echo "<a href=\"read_news.php?cid=$row['news']\">more...[/url]"; print "</td></td>"; with the following.. print "<tr><td>"; echo "<a href='read_news.php?cid=".$row['news'] ."'>more...</a>"; print "</td></td>"; Hope this will solve your issue. Regards,
  16. Hello, Simply give the new name while uploading file as... $target = $target . $new_file_name; and will save the uploaded file with the new name that you want to save with. Hope this will solve your issue. Regards,
  17. Hello, There are 2 Basic mistakes in your code which let you error. - Missing with the closing brace for while condition. See your code.. while ($row = mysql_fetch_array($sql) { and it should be.. while ($row = mysql_fetch_array($sql)) { - Another big mistake is you were fetching records without executing the query. See your code below.. $sql = 'SELECT * FROM `forums` LIMIT 0, 30 '; while ($row = mysql_fetch_array($sql) { and it should be.. $sql = mysel_query('SELECT * FROM `forums` LIMIT 0, 30 ') or die(mysql_error()); while ($row = mysql_fetch_array($sql)) { Hope this will solve your issue. Regards
  18. Hello, yes i agree with php_dave, i think you are looking for something like following script.. <?php $_POST['test'] = 'test'; $_POST['test1'] = 'test1'; foreach($_POST as $key => $value) { $$key = $value; } print_r($test); print_r('<br>'.$test1); ?> Regrds,
  19. Hello, Please more clarify your issue, so that some one can reply. Better if you give an example with your code. Regards,
  20. Hello, Basically, some how you need to reload the page once user gets logout as without reloading the page the new record information will not be displayed.. Regards,
  21. Hello, You can do this by using preg_match. See the given example for reference. Lets us consider the form is posted with a filled textbox having name as 'txtName' $result = preg_match("/^(\d+)+$/", $_POST['txtName']); // Executes if match found if ($result !=0) { echo "<center><font color='#FF0000'>Entered number is valid number :: </font>".$_POST['txtName']."</center><br>"; } // else execute else { echo "<center><font color='#FF0000'>Entered text is invalid :: </font>".$_POST['txtName']."</center><br>"; } Hope this might solve your issue. Regards,
  22. Hello, That problem is because of the same variable names that you are using for both the while loops, queries. Modify the variable names and see if you get the issue solved. Regards,
  23. Hello, First of all, you made the button to act as a link and in code you are missing with a closing of anchor tag ie </ a>. Other then this the script should work and should take you to 'delete.php'. If it is not taking then explain what exact error you are getting for the same. Regards
  24. Hello, One of the following way to include option for 'All months' is ... <?php echo 'Filter by month:'; echo '<select name="month" style="margin:0 0 0 4px;" class="medium">'; echo '<option value="?month=">All months</option>'; // loop months for($x=0;$x<12;$x++){ $time = strtotime("$x months ago"); $month = date('F Y',$time); $link = strtolower(date('M',$time)); if(isset($_GET['month']) && $link == $_GET['month']) { echo '<option value="'.$link.'" selected="selected">'.$month.'</month>'; } else { echo '<option value="'.$link.'">'.$month.'</month>'; } } echo '</select>'; echo '<input type="submit" value="Filter" class="submit" />'; ?> Hope, this might solve your issue. Regards,
  25. Hello, On page submit you can check for the file size, you will be getting the currently uploaded file's size in '$_FILES' variable and also from the $_FILES['img']['name'] parameters you can find the extension for the current file. So in short, on page submit check the size and extension of the image and if it suits your requirements the allow upload else redirect on the same page with error message. Regards,
×
×
  • 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.