Jump to content

lewis987

Members
  • Posts

    214
  • Joined

  • Last visited

    Never

Everything posted by lewis987

  1. oops, posted the less uptodate code, here is the latest: <?PHP include 'db.inc.php'; mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($dbname); $files = $dbprfx . "files"; if($_POST['delete']){ $file = $_POST['file_name']; $id = $_POST['id']; $query1 = mysql_query("SELECT * FROM $files WHERE id = '$id'"); if(mysql_num_rows($query1) == 1) { $query2 = mysql_query("DELETE FROM $files WHERE `id` = '$id' LIMIT 1"); if(!$query2){ echo "cannot find the specified file in the database."; } else { $folder = "files/ " . $id . "/" . $file; unset($folder); echo "File deletetion complete!"; ?> <meta http-equiv="refresh" content="5; url=?myAccount" /> <?PHP } } } else { $querysql3 = "SELECT * FROM `drw_uploader_files` WHERE `owner` = 'admin';"; echo $querysql3; $query3 = mysql_query($querysql3); ?> <table border="0" cellspacing="0" cellpadding="0"> <?PHP if(mysql_num_rows($query3) != 1){ echo "<tr>"; echo "<td>"; echo "<strong>You have no files uploaded!</strong>"; echo "</td>"; echo "</tr>"; } else { while($row1 = mysql_fetch_array($query3, MYSQL_ASSOC)){ $file_id = $row1['id']; $file_name = $row1['file']; echo "<tr>"; echo "<td>" . $row1['id'] . "</td>"; echo "<td>" . $row1['file'] . "</td>"; echo "<td>" . $row1['size'] . "</td>"; echo "<td>" . $row1['downloads'] . "</td>"; echo "<td>" . '<form action="" method="post" name="zz"> <input name="file_name" type="hidden" value="<?PHP echo $file_name; ?>" /> <input name="file_id" type="hidden" value="<?PHP echo $file_id; ?>" /> <input name="delete" type="submit" value="Delete?" /></form>' . "</td>"; echo "</tr>"; die("linetest"); //check to see if it gets here } } ?> </table> <?PHP } ?>
  2. try this: <?PHP if($_GET['act'] == 'next'){ include 'xxxx.php'; // or use code... } else { include 'xxxx.php'; // or use code... } ?>
  3. here is the whole page: <?PHP include 'db.inc.php'; mysql_connect($dbhost,$dbuser,$dbpass); mysql_select_db($dbname); $files = $dbprfx . "files"; if($_POST['delete']){ $file = $_POST['file_name']; $id = $_POST['id']; $query1 = mysql_query("SELECT * FROM $files WHERE id = '$id'"); if(mysql_num_rows($query1) == 1) { $query2 = mysql_query("DELETE FROM $files WHERE `id` = '$id' LIMIT 1"); if(!$query2){ echo "cannot find the specified file in the database."; } else { $folder = "files/ " . $id . "/" . $file; unset($folder); echo "File deletetion complete!"; ?> <meta http-equiv="refresh" content="5; url=?myAccount" /> <?PHP } } } else { $querysql3 = "SELECT * FROM `drw_uploader_files` WHERE `owner` = 'admin';"; echo $querysql3; $query3 = mysql_query($querysql3); ?> <table border="0" cellspacing="0" cellpadding="0"> <?PHP while($row1 = mysql_fetch_array($query3, MYSQL_ASSOC)){ $file_id = $row1['id']; $file_name = $row1['file']; echo "<tr>"; echo "<td>" . $row1['id'] . "</td>"; echo "<td>" . $row1['file'] . "</td>"; echo "<td>" . $row1['size'] . "</td>"; echo "<td>" . $row1['downloads'] . "</td>"; echo "<td>" . '<form action="" method="post" name="zz"> <input name="file_name" type="hidden" value="<?PHP echo $file_name; ?>" /> <input name="file_id" type="hidden" value="<?PHP echo $file_id; ?>" /> <input name="delete" type="submit" value="Delete?" /></form>' . "</td>"; echo "</tr>"; die("linetest"); //check to see if it gets here } ?> </table> <?PHP } ?> if i put the die() after the while loop then it shows, but if i put it inside the loop it doesnt show as if it doesnt show anything even though there is definitely something in the database.
  4. ok, i tried the code, it didnt fail, but i did try the die() in the while loop and it isnt showing the text ???
  5. you can code it in php but it will take alot of coding
  6. if you mean to debug them, then dreamweaver with the php debugger would be your best bet, but to view them there is no other way apart from install apache with php or using xampp on a pen drive
  7. sure, here: SELECT * FROM drw_uploader_files WHERE `owner` = 'admin' Thats the sql, cant find the damn error anywhere
  8. i have a mysql database to check what files have been uploaded by who in a table. The table consits of of these columns: id, file, downloads, size, owner My problem is when i attempt to get the rows from the database it doesnt show anything but i have a row with the following data: id = 0 file = tt.txt downloads = 0 owner = admin size = 34 This is the code: $querysql3 = "SELECT * FROM $files WHERE `owner` = 'admin'"; echo $querysql3; $query3 = mysql_query($querysql3); ?> <table border="0" cellspacing="0" cellpadding="0"> <?PHP while($row1 = mysql_fetch_array($query3)){ $file_id = $row1['id']; $file_name = $row1['file']; echo "<tr>"; echo "<td>" . $row1['id'] . "</td>"; echo "<td>" . $row1['file'] . "</td>"; echo "<td>" . $row1['size'] . "</td>"; echo "<td>" . $row1['downloads'] . "</td>"; echo "<td>" . '<form action="" method="post" name="zz"> <input name="file_name" type="hidden" value="<?PHP echo $file_name; ?>" /> <input name="file_id" type="hidden" value="<?PHP echo $file_id; ?>" /> <input name="delete" type="submit" value="Delete?" /></form>' . "</td>"; echo "</tr>"; } ?> </table> <?PHP } ?> $files is defined earlier in the page. The sql is perfectly fine, i checked with phpMyAdmin 2.10.1, just the while loop isnt working, thanks in advance
  9. make a free one on swiftphp or something.
  10. basically to functions to get the free size left on the hard-drive and another to get the total space on it. code below. $dir = $server1['data']; $size = disk_total_space($dir); function formatTotal($size){ switch (true){ case ($size > 1048576): $size /= 1048576; $suffix = 'MB'; break; case ($size > 1024): $size /= 1024; $suffix = 'KB'; break; default: $suffix = 'B'; } return round($size, 2).$suffix; } $goose = disk_free_space($dir); function zz($goose){ switch (true){ case ($size > 1048576): $size /= 1048576; $suffix = 'MB'; break; case ($size > 1024): $size /= 1024; $suffix = 'KB'; break; default: $suffix = 'B'; } return round($size, 2).$suffix; } if i echo $goose it shows the space in bytes but i want it to show it in MB or KB depending on the size. Im on PHP 4.4.9 (i believe). Basically its when i cann formatTotal it shows the total space (that one works fine) but when i call "zz" it just shows me "0B" and when i show $goose i get the proper size in bytes.
  11. or you can use this simple code: $rand1 = rand(3,86); $rand2 = rand(25,66); $random_number = mktime() * $rand1 + $rand1 * $rand2;
  12. ok, im starting out on ajax after being in php for about a month, so im wondering if anyone can point me in a direction of a tutorial (or preferablly make one). Im coding my own shoutbox, at the minute i have the whole backbone, i can instert shouts and talk, but i cant make the shouts reload. thats all im wanting to do. anything else im willing to post
  13. it didnt want to show the first table row for some reason, i rewrote the code and it now works
  14. arent you meant to fulfil the name of the session? instead of: $_SESSION = $row; shouldnt it be: $_SESSION['NAME_OF_SESSION'] = $row['NAME_OF_COLUMN']
  15. try this: SELECT * FROM `forum_posts` WHERE `post_body` LIKE CONVERT( _utf8 '%keywords%' USING latin1 )
  16. well doesnt make a difference but here is the full code of my footer (it gets inculded in the main page) page: the part that im having trouble with is near the end the main problem is its not showing the very first result <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td valign="middle" width="100px"> <?PHP $themes=$prefix."themes"; $themeboxsql="SELECT * FROM $themes LIMIT 100"; $themeboxresult=mysql_query($themeboxsql); $themes=mysql_fetch_array($themeboxresult); ?> <form action="<?PHP $PHP_SELF; ?>?idx&st=<?PHP echo $themes['id'] ?>" method="post"> <select name="theme"> <option class="tbl">--Themes--</option> <?php while ($themes=mysql_fetch_array($themeboxresult)){ echo "<option value='{$themes['id']}' class='tbl2'>{$themes['name']}</option>"; } ?> </select> <input name="go" type="image" width="12" height="12" title="Change Skin" src="<?PHP echo $path2; ?>img/go.gif" /> </form> </td> <td> </td> </tr> </table> <?PHP if($user){ ?> <table width="100%" border="0"> <tr> <td width="13%"><a href="http://www.php.net" onMouseOver="image1.src=loadImage1.src;" onMouseOut="image1.src=staticImage1.src;" target="_blank"><img src="<?PHP echo $path2;?>img/php-gray.gif" name="image1" width="90" height="50" border=0></a></td> <td width="14%"><a href="http://www.mysql.com" onMouseOver="image2.src=loadImage2.src;" onMouseOut="image2.src=staticImage2.src;" target="_blank"><img src="<?PHP echo $path2;?>img/mysql-color.gif" name="image2" border=0></a></td> <td width="46%"> </td> <td width="14%"><a href="http://www.mysql.com" onMouseOver="image3.src=loadImage3.src;" onMouseOut="image3.src=staticImage3.src;" target="_blank"><img src="<?PHP echo $path2;?>img/mysql-color.gif" name="image3" border=0></a></td> <td width="13%"><a href="http://www.php.net" onMouseOver="image4.src=loadImage4.src;" onMouseOut="image4.src=staticImage4.src;" target="_blank"><img src="<?PHP echo $path2;?>img/php-gray.gif" name="image4" width="90" height="50" border=0></td> </tr> </table> <?PHP }else{ ?> <table width="100%" border="0"> <tr> <td width="13%"><a href="http://www.php.net" onMouseOver="image1.src=loadImage1.src;" onMouseOut="image1.src=staticImage1.src;" target="_blank"><img src="<?PHP echo $path1;?>img/php-gray.gif" name="image1" width="90" height="50" border=0></a></td> <td width="14%"><a href="http://www.mysql.com" onMouseOver="image2.src=loadImage2.src;" onMouseOut="image2.src=staticImage2.src;" target="_blank"><img src="<?PHP echo $path1;?>img/mysql-color.gif" name="image2" border=0></a></td> <td width="46%"> </td> <td width="14%"><a href="http://www.mysql.com" onMouseOver="image3.src=loadImage3.src;" onMouseOut="image3.src=staticImage3.src;" target="_blank"><img src="<?PHP echo $path1;?>img/mysql-color.gif" name="image3" border=0></a></td> <td width="13%"><a href="http://www.php.net" onMouseOver="image4.src=loadImage4.src;" onMouseOut="image4.src=staticImage4.src;" target="_blank"><img src="<?PHP echo $path1;?>img/php-gray.gif" name="image4" width="90" height="50" border=0></td> </tr> </table> <?PHP } ?> </body> </html> yes its messy but i will sort it out...
  17. ill try it not working fully i have 3 entries and its only showing 2 :S
  18. i have a selection box that should show up all the items i have in the database, but instead its only showing one. Code below <?PHP $themes=$prefix."themes"; $themeboxsql="SELECT * FROM $themes LIMIT 0,100"; $themeboxresult=mysql_query($themeboxsql); $themes=mysql_fetch_array($themeboxresult); ?> <form action="?idx&st=<?PHP echo $themes['id'] ?>" method="post"> <select name="theme"> <option class="tbl">--Themes--</option> <option value="<?PHP echo $themes['id']; ?>" class="tbl2"><?PHP echo $themes['name'] ?></option> </select> <input name="go" type="image" width="12" height="12" title="Change Skin" src="<?PHP echo $path2; ?>img/go.gif" /> </form>
  19. ok, that didnt work either but i found the error.
  20. well, i want PHP to query a table to get the theme that the use has set, then query another database to get the path of the theme so like this Q1=get theme from user settings table Q2=Get theme Path from theme table Here is my code: //SELECT CORRECT THEME if($user){ $themesql2=mysql_query("SELECT * FROM `$settings` WHERE `user` = '$user'"); $themerows2=mysql_fetch_array($themesql2); $theme=$themerow['theme']; $themesql1="SELECT * FROM `drw_themes` WHERE `name` = '$theme'"; $themeresult1=mysql_query($themesql1); $themerows1=mysql_fetch_array($themeresult1); $path2=$themerows1['path']; echo $themesql1; ?> <link href="<?PHP echo $path2; ?>style.css" rel="stylesheet" type="text/css" /> <?PHP } else { $defaultsql=mysql_query("SELECT * FROM $themes WHERE `name`='default'"); $defaultrows=mysql_fetch_array($defaultsql); $path1=$defaultrows['path']; ?> <link href="<?PHP echo $path1; ?>style.css" rel="stylesheet" type="text/css" /> <?PHP }
  21. you want to be able to read it you mean? if so grab dreamweaver or even notepad and look at it, as for converting it to html, i suggest you dont do this, most of the php data will be lost
  22. got it working! the code had to be: $banned = mysql_query("SELECT * FROM $tblbanned WHERE `username`='$user'"); $rows=mysql_fetch_array($banned); if($datetime > $rows['banend']){ mysql_query("UPDATE $tblbanned SET `banned` = '0' WHERE `username`='$user'"); } rather than: $banned = mysql_query("SELECT * FROM $tblbanned WHERE `username`='$user'"); $rows=mysql_fetch_array($banned); if($datetime >= $rows['banend']){ mysql_query("UPDATE $tblbanned SET `banned` = '0' WHERE `username`='$user'"); }
  23. put the field username as unquie. i dont know the code to check with PHP off-hand
×
×
  • 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.