PHP - Php Engine Not Picking Up Mysql While Script
Hiya guys,
I'm having problems with a code i have written, it seems that nor google or my own search engine is picking up the links? And i don't understand why. I know the following code has a div on click rule, but i have also added an a href. I tried the basic link which is also not picking up. Code: [Select] <?php $old_pattern = array("/[^a-zA-Z0-9]/", "/_+/", "/_$/"); $new_pattern = array("_", "_", ""); $i = '1'; while($row = mysql_fetch_array($result)) { ${videoData_.$i} = mysql_query("SELECT * FROM videoData WHERE qid=".$row['id']."") or die(mysql_error()); ${row_.$i} = mysql_fetch_array(${videoData_.$i}); ${vote_.$i} = mysql_query("SELECT SUM(votes) FROM answers WHERE qid=".$row['id']."")or die(mysql_error()); ${votes_.$i} = mysql_fetch_array(${vote_.$i}); $pagelink = strtolower(preg_replace($old_pattern, $new_pattern , $row['question'])); echo '<div class="NVP-div" '; echo 'onclick="location.href=\'http://www.thevideopoll.com/polls/'; echo $link = "".$row['id']."-_-".$pagelink.".php"; echo '\';" style="cursor: pointer;"'; echo '>'; echo '<img style="float:left; margin-left:25px;" src="http://img.youtube.com/vi/'.${row_.$i}['videoID'].'/default.jpg">'; echo '<p class="NVP-vote">'; echo ${votes_.$i}['SUM(votes)']; echo ' Votes'; echo '</p>'; echo '<br>'; echo '<a class="new-video-links" href="http://www.thevideopoll.com/polls/'; echo $link = "".$row['id']."-_-".$pagelink.".php"; echo '" title="'.$row['question'].'">'; echo "".$row['question'].""; echo "</a>"; echo '</div>'; $i++; } ?> Similar TutorialsHi guys, For a project I made sort of a custom cron database. Database has 4 columns: ID (auto increment), TaskID, DateTime, Locked. I'm running a 1 minute cron in the form of a php script. The script itself starts with a query that loads a task with 'Locked != 'Y' and DateTime < NOW( ). It then locks the task (by flagging the 'Locked' field in the db) and launches another script that finishes it. That last script deletes the task when finished from the cron database. Problem is, at certain peek hours, the system would get laggy, there'd be a bunch of tasks stacking up and it would get behind on the schedule. In order to combat that, I made an extra 1 minute cron, launching the same script. Now, my problem: mysql is too slow In principle, there shouldn't be any problem: all tasks picked up by either instance of the script would be locked so the other instance wouldn't be able to pick up the same task. The problem occurs when both instances are booted at the same time (well, one after the other but with a minuscule time difference between them) and they both at the same time run the query to get a 'free' task from the database: the system will give them both the same task before either of the script instances has the time to lock it up. I'm trying to think of some solutions but I'd like your feedback on what solution would be best. - Putting an exclusive lock on the php file is not an option for me since I still want to run the script, I just need it to pick up an exclusive task. - Other option: having the script open with a random sleep of (1, 10) seconds, it will have the script instances pick up a task at a different time, giving the other instance time to lock it up. Obvious disadvantage: I'm losing time. - Using a file as a flag. Set a directory and create a file in it. Check if this is the only file in the dir, if yes: start right away. Otherwise: go to sleep for 2 seconds (should be plenty of time to run 2 queries in the other instance). What is the fastest method of doing a directory scan though, glob()? My question: what's the fastest/best way to solve this? Thanks! Hi good people, i'm vary new in this and i'm having trouble with PHP while writing some project for school and because i find many answers on this forum till now i decide to post this.. so here is my problem: I'm trying to make a web page for students and profesors where students (when they are loged in) will be able to sign a date for their exam so i made a form like this : Code: [Select] <form method="POST" action=""> choose exam: <p><select name="exams"> <option value="k1D">exam 1</option> <option value="k2D">exam 2</option> <option value="k3D">exam 3</option> </select></p> choose date: <p><select name="dates"> <optgroup label="Zimski rokovi"> <option value="2011-02-01">01.02.2011.</option> <option value="2011-02-07">07.02.2011.</option> <option value="2011-02-15">15.02.2011 </option> <optgroup label="Ljetni rokovi"> <option value="2011-05-21">21.05.2011.</option> <option value="2011-05-28">28.05.2011.</option> <option value="2011-06-04">04.06.2011.</option> </select></p> <input type="submit" value="Prijavi ispit" name="prijavi"> </form> table for students in mysql has columns for every exam (k1D , k2D..) but how can i make so that student can pick wich exam he wants to sign on some of dates (wich column he wants to fill with wich of dates) ? i tryed some variations of : Code: [Select] $k1D = $_POST['dates']; $kol = $_POST['exams']; mysql_query(" UPDATE studenti SET '$kol' = '$k1D' WHERE ID = '3'"); but i'm just getting different errors.. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=326179.0 Hi, I'm am trying to use a search engine that search's for a username in the database and displays the information back. I have searched for a script but none of them has helped me. I have tried to use this without any luck: mysql_connect("localhost", "", "") or die(mysql_error()); mysql_select_db("dbsystem") or die(mysql_error()); $todo=$_POST['todo']; if(isset($todo) and $todo=="search"){ $search_text=$_POST['search_text']; $type=$_POST['type']; $search_text=ltrim($search_text); $search_text=rtrim($search_text); if($type<>"any"){ $query="select * from users where name = '$search_text'"; }else{ $kt=split(" ",$search_text);//Breaking the string to array of words // Now let us generate the sql while(list($key,$val)=each($kt)){ if($val<>" " and strlen($val) > 0){$q .= " name like '%$val%' or ";} }// end of while $q=substr($q,0,(strlen($q)-3)); // this will remove the last or from the string. $query="select * from users where $q "; } // end of if else based on type value echo $query; echo "<br><br>"; $nt=mysql_query($query); echo mysql_error(); while($row=mysql_fetch_array($nt)){ echo "$row[name]<br>"; } // End if form submitted }else{ echo "<form method='post' action=''><input type='hidden' name='todo' value='search' /> <input type='text' name='search_text' /><input type='submit' value='Search' /><br> <input type='radio' name='type' value='any' checked />Match any where <input type='radio' name='type' value='exact' />Exact Match </form> "; } I will be grateful if you can help with this. Hey guys, I have a url that looks like this http://www.mysite.com/our-company-t-2.html I need to extract the number at the end. It's 2 here but could be 2478 for example. Just wondering how I can do this. Would it need to do something like look for anything between "-" and ".html" ? Using phpMyAdmin I loaded 6 test records with the id set to auto_increment and it loaded all the data correctly with id # 1-6. Then from somewhere it got the number 333353 and auto_increments it as the value for the id. So now I have id's 1-6 and 333353, 333354, ect. For every record I add it increments it. I deleted all but records 1-6 and tried again but it has the last value of 3333xx stored somewhere and increments it. Deleted them again, closed the program, came back and it still does it.
I have 3 staff members that need to pick vacation in a certain order.
~~~~~~First round of picking~~~~~~
Staff 1 takes 2 Weeks
~~~~~~Second round of picking~~~~~~
Staff 1 takes 1 Weeks
~~~~~~Third round of picking~~~~~~
Staff 1 Skipped
~~~~~~~~~~~~ --calendar.php-- $year=2020; $sql = "SELECT * FROM vac_admin WHERE pick_year='$year'; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { $row_admin = mysqli_fetch_assoc($result); } $current_pick_staff = $row_admin['current_pick_staff']; $sql = "SELECT * FROM vac_pick_order WHERE pick_year='$year' && pick_order = '$current_pick_staff'"; $result = mysqli_query($conn, $sql); $row = mysqli_fetch_assoc($result); if($row['vac_c_counter'] < 0){ $emp_num = $row['emp_num']; }ELSE{ ?????????????????? goto next staff with weeks > 0 ?????Somthing like if ($current_pick_staff == 3){ $current_pick_staff = 1; }ELSE{ $current_pick_staff++; } ?????????????????? } ~<FORM>~~~~~~~~~~~~~~~~~~~~~ Staff with $emp_num can now pick ~~~~~~ $_POST -> $date = XXXX-XX-XX; $num_weeks = X; $emp_num; ~</FORM>~~~~~~~~~~~~~~~~~~~~~ --process.php-- $year = 2020; $date = $_POST['date']; $num_weeks = $_POST['num_weeks']; $emp_num = $_POST['emp_num']; $sql = "INSERT INTO vac_picks (pick_year,emp_num,date) VALUES ($year,$emp_num,$date)"; $sql = "UPDATE vac_pick_order SET vac_c_counter=vac_c_counter - $num_weeks WHERE emp_num='$emp_num'; $sql = "UPDATE vac_admin SET pick_order=pick_order +1 WHERE pick_year='$year' ; Then back to calendar.php until all weeks gone.
I want to know how to display results from mysql database by filling in a form. but i have found a tutorial which shows typing in a text box which displays results. if i follow this tutorial will it help me to understand and create php coding to display results for my form? Hi, Can anyone help me with a script, I have tried a if statement but I cannot get it to work and its driving me mad. Basically I have a string my website uses to get if the user is logged in what their username is and I want it so when they click a certain link it checks to see if a table all ready exists called their username, if it does it displays a message, if it doesnt it creates the table and if the username is "anonymous" is displays a message. So in short: if $username is the same as a table display "Table all ready exists" if $username="anonymous" display "You must be logged int" if $username not the same as a table then create table. Many thanks in advance Jay hi i am having a problem with a php script. i have 3 files index.php, home.html.php, form.html.php. home.html.php is working fine, if has a form that is submitting fine but when it submits i get a problem. maybe someone can help me out please i would be grateful as i am new. the is nothing wrong with anything else mysql database is running fine and there is no problem with connection. index.php (you can ignore what is commented out) <?php include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php'; //$_GET['id'] is categoryid if (isset($_GET['id'])) { include $_SERVER['DOCUMENT_ROOT'] . '/includes/db.inc.php'; $id = mysqli_real_escape_string($link, $_GET['id']); $sql = "SELECT businessid FROM businesscategory WHERE categoryid LIKE '$id'"; $result = mysqli_query($link, $sql); if ($result !='') { $businessid = mysqli_fetch_array($result); $sql = "SELECT content FROM business WHERE id LIKE '$businessid'"; $result = mysqli_query($link, $sql); } if ($result !='') { $content = mysqli_fetch_array($result); include 'form.html.php'; exit(); } } /* // The basic SELECT statement $select = 'SELECT content'; $from = ' FROM business'; $where = ' WHERE TRUE'; $id = mysqli_real_escape_string($link, $_GET['id']); if ($category != '') // An owner is selected { $where .= " AND categoryid='$categoryid"; } $categoryid = mysqli_real_escape_string($link, $_GET['category']); if ($categoryid != '') // A category is selected { $from .= ' INNER JOIN businesscategory ON id = business'; $where .= " AND categoryid='$categoryid'"; } $text = mysqli_real_escape_string($link, $_GET['text']); if ($text != '') // Some search text was specified { $where .= " AND content LIKE '%$text%'"; } $result = mysqli_query($link, $select . $from . $where); if (!$result) { $error = 'Error fetching businesses.'; include 'error.html.php'; exit(); } while ($row = mysqli_fetch_array($result)) { $businesses[] = array('id' => $row['id'], 'text' => $row['content']); } include 'form.html.php'; exit(); } */ $result = mysqli_query($link, 'SELECT id, name FROM category ORDER BY name'); if (!$result) { $error = 'Error fetching categories: ' . mysqli_error($link); include 'error.html.php'; exit(); } while ($row = mysqli_fetch_array($result)) { $categories[] = array('id' => $row['id'], 'text' => $row['name']); } include 'home.html.php'; ?> form.html.php <?php include_once $_SERVER['DOCUMENT_ROOT'] . '/includes/helpers.inc.php'; ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <meta name="generator" content="PSPad editor, www.pspad.com"> <title>Business</title> </head> <body> it works <?php echo $content; ?> </body> </html> Hello, I'm new to this website so forgive me if I'm posting in the wrong section. I just need to know if there is a way that I can retrieve php script that is stored in a database? for example, in my database in table: <? echo"Hello World"; ?> and in my php file, I call that using: <? mysql_connect("asdas","asdas","asd"); mysql_select_db("asdasda"); $result = mysql_query("select * from somedatabse"); while($r=mysql_fetch_array($result)) { $table=$r["table"]; } echo"$table"; ?> i know its confusing, i just hope i made sense and that someone understands what im trying to do. any help will be appreciatedddd thank you : ) hello guys. i sitting here at my pc , have used alot days on google and forums. but i just cant seem to find what i am looking for so i hope that anyone here got a min to tell me what to do okai soo what i am looking for is a php / mysql script that can countdown for a user , when its finish add a number ( to usertabel[2]. and the problem is it need to do it also if the user closes the browser. i am total lost , have no ide to fix / wihte it Sorry for my spelling i am danish TRUNCATE TABLE CubeCart_cats_idx; INSERT INTO CubeCart_cats_idx (productid, cat_id) SELECT productid, cat_id FROM CubeCart_inventory; I an running the following in MyPHPAdmin, but need this to be automated in a PHP script, how would I do it ? all help is appreciated, still new to PHP & MySQL many thanks D Please help ! Hi guys, I am literally at my wits end with this and I am almost positive its in my code. This code is from a blackberry app that sends the infor into PHP, that part works flawlessy and was working just fine until I added the code to get the supervisor email from a different table based off a query. What happens is the information gets posted three times, The first time the emails are triggered and the post happens succefully, both the user and the supervisor get the properly formatted emails. This happens almost immediately, works great. Then almost immediately, the supervisor will get two more emails, with the same information except missing the orignal users email, presumably the user would have gotten two more emails as well if the email address was available. The mysql DB gets all 3 records with the second two missing the user email. Here is my code: <?php $dbServer1='contractor.emcee.tv'; $dbUser1='******'; $dbPass1='******'; $dbName1='purchaseorders'; $link = mysqli_connect("$dbServer1", "$dbUser1", "$dbPass1") or die("Could not connect post"); mysqli_select_db($link,"$dbName1") or die("Could not select database your_db_name1"); $job = $_GET['jobnumber']; $vend = $_GET['vendor']; $cat = $_GET['category']; $amt = $_GET['amount']; $note = $_GET['note']; $email = $_SERVER['HTTP_RIM_DEVICE_EMAIL']; $sql = mysqli_query($link,"insert po (job,vend,cat,amount,user,notes,date) values ('$job','$vend','$cat','$amt','$email','$note',NOW())"); if (!$sql){ print("FAILED"); } else { print("SUCCESS"); $query = "SELECT MAX(id) AS PO from po"; $result = mysqli_query($link, $query) Or die(mysqli_error($link)) ; while ($row = mysqli_fetch_assoc($result)) { $po = $row['PO']; } $query2 = "SELECT supervisoremail FROM job WHERE jobnum = $job"; $result2 = mysqli_query($link, $query2)Or die(mysqli_error($link)); while ($row2 =mysqli_fetch_assoc($result2)){ $sup = $row2['supervisoremail']; } $subject = "Purchase Order Request"; $supsubject = "FYI Purchase Order Completion"; $body = "Your purchase order request has been completed. \n \n Your PO number is: $po \n \n Job Number:$job \n Vendor:$vend \n Category:$cat \n Amount:$amt \n Items: \n $note \n \n A copy of this email has been sent to your supervisor."; $supbody = "A purchase order request has been completed. \n \n PO number $po was issued to $email for the following: \n \n Job Number:$job \n Vendor:$vend \n Category:$cat \n Amount:$amt \n Items: \n $note \n \n Please address this if this request is in error."; mail($email, $subject, $body); mail($sup, $supsubject, $supbody); } ?> Hello. i am writing an API for lua... that sends POST requests to a php script. this php script is malfunctioning. below is the code and error. Hey guys! I'm not that good with PHP, and I really need to finish this script. I'm having a hard time finding the problem..it keeps saying Error, query failed and I've also checked the database info, connectivity info and even tried a connection and database selection verification to see if that was working. Is there any other error you guys can find in the script that may be causing the message? Edit: The files I want to be able to upload should be pdf's, txts, docs, etc. Would that be possible with this script? Thanks!! Code: [Select] <form method="post" enctype="multipart/form-data"> <table width="350" border="0" cellpadding="1" cellspacing="1" class="box"> <tr> <td width="246"> <input type="hidden" name="MAX_FILE_SIZE" value="104857600"></td> <td width="80"> </td> </tr> </table> <p>Archivo: <input name="userfile" type="file" id="userfile" /> </p> <p>Nomb <label for="name"></label> <input type="text" name="nombrelista" id="nombrelista" /> </p> <p>Password (para luego borrar si necesario): <input type="text" name="pass" id="pass" /> </p> <p> <input name="upload" type="submit" class="box" id="upload" value=" Upload " /> </p> <?php if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $filePass = $_POST['pass']; $nombreLista = $_POST['nombrelista']; $fp = fopen($tmpName, 'r'); $content = fread($fp, filesize($tmpName)); $content = addslashes($content); fclose($fp); $host_db = "localhost"; $user_db = "melkien_rudesa"; $pass_db = "jorlan2407"; $base_db = "melkien_rudesa"; $link = mysql_connect($host_db, $user_db, $pass_db); if (!$link) { die('Could not connect: ' . mysql_error()); mysql_close($link); } mysql_select_db($base_db, $link) or die(mysql_error()); if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); } $query = "INSERT INTO 'upload'('nombrelista', 'name', 'pass', 'size', 'type', 'content' ) VALUES ('$nombreLista', $fileName', '$filePass', $fileSize', '$fileType', '$content')"; mysql_query($query) or die('Error, query failed'); echo "<br>File $fileName uploaded<br>"; mysql_close($link); } ?> </form> Hi, Im just in the middle of creating an update script for my mysql database but don't know why it's not working. p.s. I'm a little new to PHP, but know quite a bit, it's probably something really small.. *facepalm* Here's the script: the form (update.php) <? // Connect to the database $link = mysql_connect('###', '###', '###'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db('###', $link); $id = $_GET['id']; // Ask the database for the information from the links table $query="SELECT * FROM orders WHERE id='$id'"; $result = mysql_query("SELECT * FROM orders"); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $name=mysql_result($result,$i,"Name"); $location=mysql_result($result,$i,"Location"); $fault=mysql_result($result,$i,"Fault"); ?> <form action="updated.php" method="post"> <input type="hidden" name="ud_id" value="<? echo "$id";?>"> Name: <input type="text" name="ud_name" value="<? echo "$name"?>"><br> Location: <input type="text" name="ud_location" value="<? echo "$location"?>"><br> Fault: <input type="text" name="ud_fault" value="<? echo "$fault"?>"><br> <input type="Submit" value="Update"> </form> <? ++$i; } ?> ------------------------------------------------------ (processor) updated.php <?php // Connect to the database $link = mysql_connect('###', '###', '###'); if (!$link) { die('Could not connect: ' . mysql_error()); } mysql_select_db('###', $link); $query="UPDATE orders SET Name='" . $_POST['ud_name'] . "', Location='" . $_POST['ud_location'] . "', Fault='" . $_POST['ud_fault'] . "' WHERE $id='" . $_POST['ud_id'] . "'"; echo $query; $checkresult = mysql_query($query); if ($checkresult) echo '<p>update query succeeded'; else echo '<p>update query failed'; mysql_close(); ?> ------------------------------------------------------ Every time I want to update, it comes up with: UPDATE orders SET Name='TEST', Location='TEST', fault='jbjh' WHERE ='' update query failed Any help would be appreciated. Hey everyone, I'm currently working on a friends online script and i have a slight problem that i need help with. Basically the code first searches "TBL_Friends" to see if you have any friends added. If it returns results it then turns your friends ID's into a variable. It then searches "TBL_Users_Online" to see if any body is logged based on the friend's ID it returned before. The first bit of the code works and it retrieves all the friends i got added. The second half is odd, if i have one or two friends added it will show that one is online. If i have more then three friends added it returns no results. I know my code is a bit sloppy and probably not the best way of writing it, im still learning PHP. Anyways this is the code, any help is appreciated. Code: [Select] <?php $FriendsOnline = mysql_query("SELECT Sender_ID FROM TBL_User_Friends WHERE Reciever_ID = $UserID"); while($fo=mysql_fetch_array($FriendsOnline)) { $FriendsOnlineID = $fo[Sender_ID]; $FriendsOnlineNumber = mysql_query("SELECT * FROM TBL_Users_Online WHERE User_ID = $FriendsOnlineID"); $FriendsNumber = mysql_num_rows($FriendsOnlineNumber); echo $FriendsNumber; } ?> $SenderID = Friends ID $Reciever_ID = User ID $UserID = User ID Hi, I am trying to convert the register & login script from mysql to mysqli. I have converted the easy parts and have the connection to the database, but the following functions all need changing and I can't work out the correct solution mainly due to the deprecation of mysql_result() The code that needs updating is <?php function user_count() { return mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `active` = 1"), 0); } function users_online() { return mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `logged_in` = 1"), 0); } function change_profile_image($user_id, $file_temp, $file_extn) { $file_path = 'images/profile/' . substr(md5(time()), 0, 10) . '.' . $file_extn; move_uploaded_file($file_temp, $file_path); mysql_query("UPDATE `users` SET `profile` = '" . mysql_real_escape_string($file_path) . "' WHERE `user_id` = " . (int)$user_id); } function has_access($user_id, $type) { $user_id = (int)$user_id; $type = (int)$type; return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_id` = $user_id AND `type` = $type"), 0) == 1) ? true : false; } function activate($email, $email_code) { $email = mysql_real_escape_string($email); $email_code = mysql_real_escape_string($email_code); if (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `email` = '$email' AND `email_code` = '$email_code' AND `active` = 0"), 0) == 1) { mysql_query("UPDATE `users` SET `active` = 1 WHERE `email` = '$email'"); return true; } else { return false; } } function user_exists($username) { $username = sanitize($username); $query = mysql_query("SELECT COUNT('user_id') FROM `users` WHERE `username` = '$username'"); return (mysql_result($query, 0) == 1) ? true : false; } function email_exists($email) { $email = sanitize($email); return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `email` = '$email'"), 0) == 1) ? true : false; } function user_id_from_username($username) { $username = sanitize($username); return mysql_result(mysql_query("SELECT `user_id` FROM `users` WHERE `username` = '$username'"), 0, 'user_id'); } function user_id_from_email($email) { $email = sanitize($email); return mysql_result(mysql_query("SELECT `user_id` FROM `users` WHERE `email` = '$email'"), 0, 'user_id'); } function login($username, $password) { $user_id = user_id_from_username($username); mysql_query("UPDATE `users` SET `logged_in` = 1 WHERE `user_id` = $user_id"); $username = sanitize($username); $password = md5($password); return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `password` = '$password'"), 0) == 1) ? $user_id : false; } ?>And here is what the converter gave me: function user_count() { return mysql_result(mysqli_query($GLOBALS["___mysqli_ston"], "SELECT COUNT(`user_id`) FROM `users` WHERE `active` = 1"), 0); } function users_online() { return mysql_result(mysqli_query($GLOBALS["___mysqli_ston"], "SELECT COUNT(`user_id`) FROM `users` WHERE `logged_in` = 1"), 0); } function change_profile_image($user_id, $file_temp, $file_extn) { $file_path = 'images/profile/' . substr(md5(time()), 0, 10) . '.' . $file_extn; move_uploaded_file($file_temp, $file_path); mysql_query("UPDATE `users` SET `profile` = '" . mysql_real_escape_string($file_path) . "' WHERE `user_id` = " . (int)$user_id); } function has_access($user_id, $type) { $user_id = (int)$user_id; $type = (int)$type; return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `user_id` = $user_id AND `type` = $type"), 0) == 1) ? true : false; } function activate($email, $email_code) { $email = mysql_real_escape_string($email); $email_code = mysql_real_escape_string($email_code); if (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `email` = '$email' AND `email_code` = '$email_code' AND `active` = 0"), 0) == 1) { mysql_query("UPDATE `users` SET `active` = 1 WHERE `email` = '$email'"); return true; } else { return false; } } function user_exists($username) { $username = sanitize($username); $query = mysql_query("SELECT COUNT('user_id') FROM `users` WHERE `username` = '$username'"); return (mysql_result($query, 0) == 1) ? true : false; } function email_exists($email) { $email = sanitize($email); return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `email` = '$email'"), 0) == 1) ? true : false; } function user_id_from_username($username) { $username = sanitize($username); return mysql_result(mysql_query("SELECT `user_id` FROM `users` WHERE `username` = '$username'"), 0, 'user_id'); } function user_id_from_email($email) { $email = sanitize($email); return mysql_result(mysql_query("SELECT `user_id` FROM `users` WHERE `email` = '$email'"), 0, 'user_id'); } function login($username, $password) { $user_id = user_id_from_username($username); mysql_query("UPDATE `users` SET `logged_in` = 1 WHERE `user_id` = $user_id"); $username = sanitize($username); $password = md5($password); return (mysql_result(mysql_query("SELECT COUNT(`user_id`) FROM `users` WHERE `username` = '$username' AND `password` = '$password'"), 0) == 1) ? $user_id : false; } ?>Please could someone point me in the right direction here? Also my site works perfectly well with MySQL, do I have to convert it to MySQLi? Many Thanks Paul If anyone knows how to solve this, it would be much appreciated. I already have a website template and would prefer to continue with mysqli instead of PDO. Many Thanks Paul Hello, I know i'm new, i hope it wont stop you guys from putting 5 minutes of your time to help me out. I need a script to get some data from mysql and put this into a table. i have a mysql database called "denora" In there is a table called "chan" In table chan are the columns: chanid (unique number), channel, currentusers, mode_ls I would like the script to make a html table that lists the top10 channels (most "currentusers" on top) And when "mode_ls" is "Y" it must not be shown (secret channel) My knowledge of php and mysql arent that great so i really hope someone takes the time to help me uit Kind regards Stefan |