Jump to content

Russia

Members
  • Posts

    419
  • Joined

  • Last visited

Everything posted by Russia

  1. Giz, the reason is, because I have about 100 members in my database, and if I change the column type it will default it to I think 0000000 which is very annoying.
  2. Thanks it works, but for some reason it gives this error under the usernames. Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\Program Files\EasyPHP5.2.10\www\yanille\includes\footer.php on line 34
  3. I have a database with Users as a table. It has the normal stuff, id, username, password, and I have anther in it called lastactive. It is int(11) , and I am wondering how I would make a sql query select the users in the database 'users' and see who has been active in the past 15 mins. By the way, the lastactive time gets updated by the function time() Here is my code: <?php $online = mysql_query("SELECT * from users WHERE (TIMESTAMPDIFF(MINUTE, `lastactive`, NOW()) < 15) ORDER by lastactive DESC") or die (mysql_error()); while($online = mysql_fetch_assoc($online)) { echo '<a style="color:#F0CD87;" href="profile?id='.$online['user_id'].'">'; echo ucFirst($online['username']); echo '</a>, '; } ?> Here is how the last active gets updated. <?php if(isset($_SESSION['logged'])) { mysql_query("UPDATE `users` SET `lastactive`='" . time() . "' WHERE `username`='" . $_SESSION['username'] . "'"); } ?> Again its not showing the users that have been on since 15 minutes ago, even tho it updates the users last active on every page since its in the footer.php part. which is on every page. Thanks for the upcoming help.
  4. Thanks one more thing, since the updating of a avatar is optional, how do I do it, if the person does set a new avatar it keeps the old one? Because in mine, it looks like its needed, because it wont update if a image isnt found. How do I do it so its like optional? Here is my current code. <?php if(empty($_GET['id']) ) { echo 'Category not specified'; } else { mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("chat"); $result = mysql_query("SELECT * FROM users WHERE user_id = '$_GET[id]'"); $query = mysql_fetch_array($result); if (isset($_POST['submit'])) { $target = "mainnewsimg/"; $target = $target . basename( $_FILES['photo']['name']); // Set global variables to easier names $pic=($_FILES['photo']['name']); if (($_FILES["photo"]["type"] == "image/gif") || ($_FILES["photo"]["type"] == "image/jpeg") || ($_FILES["photo"]["type"] == "image/png" ) && ($_FILES["photo"]["size"] < 10000000)) { $tmpName = $_FILES['photo']['tmp_name']; list($width, $height, $type, $attr) = getimagesize($tmpName); if($width <= 90 && $height <= 90) { if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { mysql_query("UPDATE users SET level ='". $_POST['rank'] ."', email='". $_POST['email'] ."', fname='". $_POST['fname'] ."', lname='". $_POST['lname'] ."', avatar='$pic' WHERE user_id='". $_GET['id'] ."' "); echo "user updated"; } else { echo "file hasent been moved to uploads"; } } else { echo "size too big"; } } else { echo "Files must be either JPEG, GIF, or PNG and less than 10,000 kb"; } //mysql_query("UPDATE Persons SET level = '36'WHERE user_id = '$_GET[id]'"); } ?> <?php echo $query['username']; ?> <form enctype="multipart/form-data" method="post" action=""> <table> <tbody> <tr><td class="first"></td> <td><?php echo $query['user_id']; ?></td></tr> <tr><td class="first">First Name</td> <td><input type="text" name="fname" value="<?php echo $query['fname']; ?>" ></td></tr> <tr><td class="first">Last Name</td> <td><input type="text" name="lname" value="<?php echo $query['lname']; ?>" ></td></tr> <tr><td class="first">Email</td> <td><input type="text" name="email" value="<?php echo $query['email']; ?>" ></td></tr> <tr><td class="first">Rank</td> <td><select name="rank"> <option value="0" <?php if($query['level']=="0") { echo "selected"; }?>>Unactivated</option> <option value="1" <?php if($query['level']=="1") { echo "selected"; }?>>Banned</option> <option value="2" <?php if($query['level']=="2") { echo "selected"; }?>>Regular User</option> <option value="3" <?php if($query['level']=="3") { echo "selected"; }?>>Donator</option> <option value="4" <?php if($query['level']=="4") { echo "selected"; }?>>Moderator</option> <option value="5" <?php if($query['level']=="5") { echo "selected"; }?>>Administrator</option> <option value="6" <?php if($query['level']=="6") { echo "selected"; }?>>Owner</option> </select> </td></tr> <tr><td class="first">Current Avatar</td> <td> <?php echo "<img width='90' height='90' src=mainnewsimg/".$query['avatar'] .">"; ?> </td></tr> <tr><td class="first">User Avatar</td> <td><input type="file" name="photo"></td></tr> <tr><td class="first">Joined on</td> <td><input type="text" name="join" value="<?php echo date('d-F-Y',($query['join_date'])); ?>" disabled="disabled"></td></tr> <tr><td class="first">Last Access</td> <td><input type="text" name="access" value="" disabled="disabled"></td></tr> <tr><td></td> <td> <input type="submit" name="submit" value="Edit User"> </td></tr> </tbody></table> </form> <?php } ?>
  5. Okay thanks, also one more thing, lets say the person when he is updating his profile doesnt pick a new avatar, how would I do it so the form still goes through. Because if I dont select a avatar the form doesnt go through and it gives the message: Files must be either JPEG, GIF, or PNG and less than 10,000 kb <?php if(empty($_GET['id']) ) { echo 'Category not specified'; } else { mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("chat"); $result = mysql_query("SELECT * FROM users WHERE user_id = '$_GET[id]'"); $query = mysql_fetch_array($result); if (isset($_POST['submit'])) { $target = "mainnewsimg/"; $target = $target . basename( $_FILES['photo']['name']); // Set global variables to easier names $pic=($_FILES['photo']['name']); if (($_FILES["photo"]["type"] == "image/gif") || ($_FILES["photo"]["type"] == "image/jpeg") || ($_FILES["photo"]["type"] == "image/png" ) && ($_FILES["photo"]["size"] < 10000000)) { $tmpName = $_FILES['photo']['tmp_name']; list($width, $height, $type, $attr) = getimagesize($tmpName); if($width <= 90 && $height <= 90) { if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { mysql_query("UPDATE users SET level ='". $_POST['rank'] ."', email='". $_POST['email'] ."', fname='". $_POST['fname'] ."', lname='". $_POST['lname'] ."', avatar='$pic' WHERE user_id='". $_GET['id'] ."' "); echo "user updated"; } else { echo "file hasent been moved to uploads"; } } else { echo "size too big"; } } else { echo "Files must be either JPEG, GIF, or PNG and less than 10,000 kb"; } //mysql_query("UPDATE Persons SET level = '36'WHERE user_id = '$_GET[id]'"); } ?> <?php echo $query['username']; ?> <form enctype="multipart/form-data" method="post" action=""> <table> <tbody> <tr><td class="first"></td> <td><?php echo $query['user_id']; ?></td></tr> <tr><td class="first">First Name</td> <td><input type="text" name="fname" value="<?php echo $query['fname']; ?>" ></td></tr> <tr><td class="first">Last Name</td> <td><input type="text" name="lname" value="<?php echo $query['lname']; ?>" ></td></tr> <tr><td class="first">Email</td> <td><input type="text" name="email" value="<?php echo $query['email']; ?>" ></td></tr> <tr><td class="first">Rank</td> <td><select name="rank"> <option value="0" <?php if($query['level']=="0") { echo "selected"; }?>>Unactivated</option> <option value="1" <?php if($query['level']=="1") { echo "selected"; }?>>Banned</option> <option value="2" <?php if($query['level']=="2") { echo "selected"; }?>>Regular User</option> <option value="3" <?php if($query['level']=="3") { echo "selected"; }?>>Donator</option> <option value="4" <?php if($query['level']=="4") { echo "selected"; }?>>Moderator</option> <option value="5" <?php if($query['level']=="5") { echo "selected"; }?>>Administrator</option> <option value="6" <?php if($query['level']=="6") { echo "selected"; }?>>Owner</option> </select> </td></tr> <tr><td class="first">Current Avatar</td> <td> <?php echo "<img width='90' height='90' src=mainnewsimg/".$query['avatar'] .">"; ?> </td></tr> <tr><td class="first">User Avatar</td> <td><input type="file" name="photo"></td></tr> <tr><td class="first">Joined on</td> <td><input type="text" name="join" value="<?php echo date('d-F-Y',($query['join_date'])); ?>" disabled="disabled"></td></tr> <tr><td class="first">Last Access</td> <td><input type="text" name="access" value="" disabled="disabled"></td></tr> <tr><td></td> <td> <input type="submit" name="submit" value="Edit User"> </td></tr> </tbody></table> </form> <?php } ?> I want the form to still update but like setting the value to the current image if a user didnt pick a new avatar.
  6. I have tried that, but for some reason its still not working, can you show me in my code what the working code would look like?
  7. Hey guys I have this script that edits a users profile, but the problem is that it doesnt want to upload it to the server and keeps saying. Files must be either JPEG, GIF, or PNG and less than 10,000 kb <?php if(empty($_GET['id']) ) { echo 'Category not specified'; } else { mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("chat"); $result = mysql_query("SELECT * FROM users WHERE user_id = '$_GET[id]'"); $query = mysql_fetch_array($result); if (isset($_POST['submit'])) { $target = "mainnewsimg/"; $target = $target . basename( $_FILES['photo']['name']); // Set global variables to easier names $pic=($_FILES['photo']['name']); if (($_FILES["photo"]["type"] == "image/gif") || ($_FILES["photo"]["type"] == "image/jpeg") || ($_FILES["photo"]["type"] == "image/png" ) && ($_FILES["photo"]["size"] < 10000)) { if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { mysql_query("UPDATE users SET level ='". $_POST['rank'] ."', email='". $_POST['email'] ."', fname='". $_POST['fname'] ."', lname='". $_POST['lname'] ."', avatar='$pic' WHERE user_id='". $_GET['id'] ."' "); echo "user updated"; } else { echo "file hasent been moved to uploads"; } } else { echo "Files must be either JPEG, GIF, or PNG and less than 10,000 kb"; } //mysql_query("UPDATE Persons SET level = '36'WHERE user_id = '$_GET[id]'"); } ?> <?php echo $query['username']; ?> <form method="post" action=""> <table> <tbody> <tr><td class="first"></td> <td><?php echo $query['user_id']; ?></td></tr> <tr><td class="first">First Name</td> <td><input type="text" name="fname" value="<?php echo $query['fname']; ?>" ></td></tr> <tr><td class="first">Last Name</td> <td><input type="text" name="lname" value="<?php echo $query['lname']; ?>" ></td></tr> <tr><td class="first">Email</td> <td><input type="text" name="email" value="<?php echo $query['email']; ?>" ></td></tr> <tr><td class="first">Rank</td> <td><select name="rank"> <option value="0" <?php if($query['level']=="0") { echo "selected"; }?>>Unactivated</option> <option value="1" <?php if($query['level']=="1") { echo "selected"; }?>>Banned</option> <option value="2" <?php if($query['level']=="2") { echo "selected"; }?>>Regular User</option> <option value="3" <?php if($query['level']=="3") { echo "selected"; }?>>Donator</option> <option value="4" <?php if($query['level']=="4") { echo "selected"; }?>>Moderator</option> <option value="5" <?php if($query['level']=="5") { echo "selected"; }?>>Administrator</option> <option value="6" <?php if($query['level']=="6") { echo "selected"; }?>>Owner</option> </select> </td></tr> <tr><td class="first">User Avatar</td> <td><input type="file" name="photo"></td></tr> <tr><td class="first">Joined on</td> <td><input type="text" name="join" value="<?php echo date('d-F-Y',($query['join_date'])); ?>" disabled="disabled"></td></tr> <tr><td class="first">Last Access</td> <td><input type="text" name="access" value="" disabled="disabled"></td></tr> <tr><td></td> <td> <input type="submit" name="submit" value="Edit User"> </td></tr> </tbody></table> </form> <?php } ?>
  8. Thanks, one more thing, How would I show a message if the $_GET is not set or if its empty. I have tried <?php if(!isset($_GET['id']) && empty($_GET['id']) ) { echo 'Category not specified'; } else { mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("chat"); //$strSQL = "SELECT * FROM users WHERE CharacterId = '$_GET['id']'" $result = mysql_query("SELECT level FROM users WHERE user_id = '$_GET[id]'"); $query = mysql_fetch_array($result); ?> <form id="main_form" name="main_form" method="post" action=""> <select name="rank"> <option value="0" <?php if($query['level']=="0") { echo "selected"; }?>>Unactivated</option> <option value="1" <?php if($query['level']=="1") { echo "selected"; }?>>Banned</option> <option value="2" <?php if($query['level']=="2") { echo "selected"; }?>>Regular User</option> <option value="3" <?php if($query['level']=="3") { echo "selected"; }?>>Donator</option> <option value="4" <?php if($query['level']=="4") { echo "selected"; }?>>Moderator</option> <option value="5" <?php if($query['level']=="5") { echo "selected"; }?>>Administrator</option> <option value="6" <?php if($query['level']=="6") { echo "selected"; }?>>Owner</option> </select> <input type="submit" id="main_submit" name="main_submit" value="submit" /> </form> <?php } ?> but it still shows the form if I have something like: http://localhost/yanille/edituser.php?id= Basically without the actual number after the equals sign.
  9. Hey guys, I am wanting to select a dropdown value based on the value of 'level' in the row of the user select by a $_GET. It will house the ranks of the user. Here is my script. RANK <?php mysql_connect("localhost","root","") or die(mysql_error()); mysql_select_db("chat"); $result = mysql_query("SELECT * FROM users WHERE user_id = '$_GET[id]'"); $row = mysql_num_rows($result); ?> <form id="main_form" name="main_form" method="post" action=""> <select name="rank"> <option value="0" <?php if($row['level']=="0") { echo "selected"; }?>>Unactivated</option> <option value="1" <?php if($row['level']=="1") { echo "selected"; }?>>Banned</option> <option value="2" <?php if($row['level']=="2") { echo "selected"; }?>>Regular User</option> <option value="3" <?php if($row['level']=="3") { echo "selected"; }?>>Donator</option> <option value="4" <?php if($row['level']=="4") { echo "selected"; }?>>Moderator</option> <option value="5" <?php if($row['level']=="5") { echo "selected"; }?>>Administrator</option> <option value="6" <?php if($row['level']=="6") { echo "selected"; }?>>Owner</option> </select> <input type="submit" id="main_submit" name="main_submit" value="submit" /> </form> It is not selecting for some reason at all. Can someone tell me what I am doing wrong?
  10. Thanks, also, one more thing, how would I do it so it enables the submit button once the message is Avaliable username. I have this code: <script type="text/javascript"> //function to create ajax object function pullAjax(){ var a; try{ a=new XMLHttpRequest() } catch(b) { try { a=new ActiveXObject("Msxml2.XMLHTTP") }catch(b) { try { a=new ActiveXObject("Microsoft.XMLHTTP") } catch(b) { alert("Your browser broke!");return false } } } return a; } function validate() { site_root = ''; var x = document.getElementById('uname'); var msg = document.getElementById('msg'); var submituser = document.getElementById('submituser'); user = x.value; code = ''; message = ''; obj=pullAjax(); obj.onreadystatechange=function() { if(obj.readyState==4) { eval("result = "+obj.responseText); code = result['code']; message = result['result']; if(code <=0) { x.style.border = "1px solid red"; msg.style.color = "red"; } else { x.style.border = "1px solid #000"; msg.style.color = "green"; usersubmit.style.display = 'block'; } msg.innerHTML = message; } } obj.open("GET",site_root+"js/user_availability.php?username="+user,true); obj.send(null); } </script> and the form is here: echo "<form action='' method='POST'>"; echo ' User Name : <input type="text" onblur="validate();" id="uname" name="uname" value="" /> <div id="msg"></div>'; echo "next info"; echo "<input name='step3' value='Next' id='submituser' style='display:none' type='submit' />"; echo "</form>"; I set it as display none as a default and then when the box is green for the box to show as a block. Its not showing up tho after the box becomes green
  11. Okay thanks, I managed to fix it by just switching the Avaliable and not avaliable parts.
  12. Okay, I changed it to this: <?php mysql_connect("localhost","root",""); mysql_select_db("chat"); $user = strip_tags(trim($_REQUEST['username'])); if(strlen($user) <= 0) { echo json_encode(array('code' => -1,'result' => 'Invalid username, please try again.')); die; } // Query database to check if the username is available $sql = "Select * from users where username = '$user' "; //$result = mysql_query($query); //$avaliable = mysql_num_rows($result); // Execute the above query using your own script and if it return you the // result (row) we should return negative, else a success message. //$available = true; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { echo json_encode(array('code' => 1,'result' => "Success,username $user is still available")); die; } else { echo json_encode(array('code' => 0,'result' => "Sorry but username $user is already taken.")); die; } } ?> It still returns as {"code":1,"result":"Success,username admin is still available"} What seems to be the problem?
  13. I have checked it over and I think its right. So if possible, what is correct way of making it check and give an available or not available message?
  14. Hey guys, I have this little script, but it doesn't seem to work properly. <?php mysql_connect("localhost","root",""); mysql_select_db("chat"); $user = strip_tags(trim($_REQUEST['username'])); if(strlen($user) <= 0) { echo json_encode(array('code' => -1,'result' => 'Invalid username, please try again.')); die; } // Query database to check if the username is available $query = "Select * from users where username = '$user' "; $result = mysql_query($query); $avaliable = mysql_num_rows($result); // Execute the above query using your own script and if it return you the // result (row) we should return negative, else a success message. //$available = true; if($available) { echo json_encode(array('code' => 1,'result' => "Success,username $user is still available")); die; } else { echo json_encode(array('code' => 0,'result' => "Sorry but username $user is already taken.")); die; } die; ?> It keeps returning with 'Sorry but username iunsdbsyusaddssd763b373b is already taken'. Even when I type in some random gibberish like 'iunsdbsyusaddssd763b373b' Can anyone show me why it is doing that? Thanks alot friends.
  15. Here is the final code anyone is free to use <form name="search" method="post" action="<?=$PHP_SELF?>"> Search: <input type="text" name="username" /> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> <? //This is only displayed if they have submitted the form $searching = $_POST['searching']; $find = $_POST['username']; if ($searching =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } // Otherwise we connect to our Database // We preform a bit of filtering $find = strtolower($find); $find = strip_tags($find); $find = trim ($find); //Now we search for our search term, in the field the user specified $data = mysql_query("SELECT * FROM users WHERE `username` LIKE '%$find%'"); //$data = mysql_query("SELECT username FROM `users` WHERE $find LIKE %$find%"); //And we display the results while($result = mysql_fetch_array( $data )) { echo $result['username']; echo "<br>"; echo $result['level']; echo "<br>"; echo $result['user_id']; echo "<hr>"; } //This counts the number or results - and if there wasn't any it gives them a little message explaining that // $anymatches= mysql_num_rows($data); if (mysql_num_rows($data) == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$find; } ?>
  16. How exactly would I make it select multiple columns, but only search in the 'username' column? Thus allowing me to post more information about the user found.
  17. It just doesnt show it Like its not even there but it shows the username I searched for. Lets say there are like mike, mike12, and michael If I search for 'mi' This is how it appears mike mike12 michael I also need it to show under the names it found, some more information.
  18. Okay thanks, right now it only displays the username as an echo, im trying to make it echo a few more things like the id of the user and the level they are. I tried adding while($result = mysql_fetch_array( $data )) { echo $result['username']; //NEW ADDED FIELDS echo $result['level']; echo $result['user_id']; echo "<br>"; echo "<br>"; } Those columns do exist. Basically from the search I want to display a few things.
  19. The same error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\EasyPHP5.2.10\www\yanille\users.php on line 152 Plus another one. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\EasyPHP5.2.10\www\yanille\users.php on line 160 Sorry, but we can not find an entry to match your query Thanks for the help you are providing. Error: Unknown column 'MI' in 'where clause'
  20. I have this search script, that finds a username in a table and displays it. <form name="search" method="post" action="<?=$PHP_SELF?>"> Search: <input type="text" name="username" /> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> <? //This is only displayed if they have submitted the form $searching = $_POST['searching']; $find = $_POST['username']; if ($searching =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } // Otherwise we connect to our Database // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Now we search for our search term, in the field the user specified $data = mysql_query("SELECT username FROM users WHERE upper($find) LIKE'%$find%'"); //And we display the results while($result = mysql_fetch_array( $data )) { echo $result['username']; echo "<br>"; echo "<br>"; } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches= mysql_num_rows ($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$find; } ?> For some reason it does not work and gives this message: [b]Warning[/b]: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in [b]C:\Program Files\EasyPHP5.2.10\www\yanille\users.php[/b] on line [b]153[/b] Error: Unknown column 'MI' in 'where clause' The reason it says MI is because I searched mi in the database which is part of the username in mike123 What would be the problem? I think I did make the query correct. Didn't I? Thanks for the help ahead of time.
  21. I have this script where it uploads the file name to a database plus a few more things. Main Upload form. (img_add.php) <form enctype="multipart/form-data" action="img_add.php" method="POST"> Name: <input type="text" name="name"><br> E-mail: <input type="text" name = "email"><br> Phone: <input type="text" name = "phone"><br> Photo: <input type="file" name="photo"><br> <input type="submit" value="Add"> </form> Uploader. (img_add.php) <?php //This is the directory where images will be saved $target = "mainnewsimg/"; $target = $target . basename( $_FILES['photo']['name']); //This gets all the other information from the form $name=$_POST['name']; $email=$_POST['email']; $phone=$_POST['phone']; $pic=($_FILES['photo']['name']); // Connects to your Database mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("chat") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `images` VALUES ('$name', '$email', '$phone', '$pic')") ; //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> And the one that views it. (img_view.php) It uses a get function so do it with img_view.php?img=2 <?php mysql_connect("localhost", "root", "") or die(mysql_error()) ; mysql_select_db("chat") or die(mysql_error()) ; //Retrieves data from MySQL $newsid = $_GET['img']; $data = mysql_query("SELECT * FROM `images` WHERE id ='$newsid'") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data Echo "<img src=mainnewsimg/".$info['photo'] ."> <br>"; } ?> And my database sql. CREATE TABLE IF NOT EXISTS `images` ( `name` varchar(30) DEFAULT NULL, `email` varchar(30) DEFAULT NULL, `phone` varchar(30) DEFAULT NULL, `photo` varchar(30) DEFAULT NULL, `id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; -- -- Dumping data for table `images` -- INSERT INTO `images` (`name`, `email`, `phone`, `photo`, `id`) VALUES ('sdf', 'sdfdsdsf', 'dsffsfsdf', 'arrow_forward_last.gif', 1), ('sadd', 'sadd', 'adsadasdad', 'artbottomshadr.png', 2); The values inside I had to put in manually to test if it worked for the img_view.php Anyways, It doesnt want to upload the images at all, even tho it says it did and gives the message The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory I would greatly appreciate some help, I also provided everything so you can try it on your own server too.
  22. Hey guys, I have a PHP pagination script, but for some reason the while looping part that shows each row doesnt show the css styling I have. Here is my code. <?php $tableName="news"; $targetpage = "archive.php"; $limit = 10; $query = "SELECT COUNT(*) as num FROM $tableName"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages['num']; $stages = 3; $page = mysql_escape_string($_GET['page']); if($page){ $start = ($page - 1) * $limit; }else{ $start = 0; } // Get page data $query1 = "SELECT * FROM $tableName LIMIT $start, $limit"; $result = mysql_query($query1); // Initial page num setup if ($page == 0){$page = 1;} $prev = $page - 1; $next = $page + 1; $lastpage = ceil($total_pages/$limit); $LastPagem1 = $lastpage - 1; $paginate = ''; if($lastpage > 1) { $paginate .= "<div class='paginate'>"; // Previous if ($page > 1){ $paginate.= "<a href='$targetpage?page=$prev'>previous</a>"; }else{ $paginate.= ""; } // Pages if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few? { // Beginning only hide later pages if($page < 1 + ($stages * 2)) { for ($counter = 1; $counter < 4 + ($stages * 2); $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // Middle hide some front and some back elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2)) { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $page - $stages; $counter <= $page + $stages; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // End only hide early pages else { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } } // Next if ($page < $counter - 1){ $paginate.= "<a href='$targetpage?page=$next'>next</a>"; }else{ $paginate.= "<span class='disabled'>next</span>"; } $paginate.= "</div>"; } //echo $total_pages.' Results'; // pagination echo $paginate; ?> <div class="newsBorder"> <table cellspacing="0" border="0" id="newsList" class="width100"> <tbody> <tr class="row_a"> <td width="30%" class="1 first" id="titleCat"> <b>Category</b> </td> <td width="50%" class="item" id="titleTitle"> <b>News Item</b> </td> <td width="20%" align="right" class="date"> <b>Date</b> </td> </tr> </tbody> </table> <?php while($row = mysql_fetch_array($result)) { ?> <tr class="pad"> <td valign="top"> <a href="list.ws?cat=3&page=1" class="catLink"> <img alt="" src="http://www.runescape.com/img/news/mini_customer_support.gif"> <span>Website</span> </a> </td> <td valign='middle'><a href="news.php?newsid=<?php echo $row['newsid'] ?>" class="titleLink"><?php echo $row['title']; ?> </a></td> <td valign="middle" align="right" class="date"><?php echo $row['dtime']; ?></td></tr><br> <?php } ?> </div> Here is how it looks right now: Here is how I want it to look like. Its basically everything inside the while is not formatting. I have all the CSS I need so that isnt the problem. Thanks for the help ahead of time.
  23. Finally someone that understands that I want to update only 1 field. But I have tried many things but its still not working. And yes sir I know that there is 1 row ATLEAST with the value its looking for. So why isnt it working?
  24. I have a script to update certain rows that contain certain data in them. Here is the code: if ($_POST['newstype'] == "1") { $query = mysql_query("SELECT * from `news` WHERE type='1'"); if (mysql_num_rows($query) == 1) { mysql_query("UPDATE `news` SET type = '2' WHERE type = '1' ORDER BY `news`.`dtime` ASC LIMIT 1") or die(mysql_error()); } else { echo "did not edit main news"; } } elseif ($_POST['newstype'] == "2") { $query = mysql_query("SELECT * from `news` WHERE type='2'"); if (mysql_num_rows($query) == 3) { mysql_query("UPDATE `news` SET type = '3' WHERE type= '2' ORDER BY `news`.`dtime` ASC LIMIT 1") or die(mysql_error()); } else { echo "did not edit recent news"; } } elseif ($_POST['newstype'] == "3") { $query = mysql_query("SELECT * from `news` WHERE type='3'"); if (mysql_num_rows($query) == 3) { mysql_query("UPDATE `news` SET type = '4' WHERE type= '3' ORDER BY `news`.`dtime` ASC LIMIT 1") or die(mysql_error()); } else { echo "did not edit old news"; } } else { echo "didnt update anything!"; } Here is my database structure. Why is it not updating it and always saying Did not edit main/recent/old news.
×
×
  • 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.