Jump to content

Search the Community

Showing results for tags 'php'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. Hey there, I'm pretty new to this proxy server thing and planning on getting some kind of deggree/major in computer science and I have made some pretty substantial progress just by doing some fairly superficial research. I've succesfully set up my phproxy and everything works reletively fine, except for social media sites such as facebook, twitter, myspace, etc. whenever I try to go to these pages via my proxy, it loads just fine but the screen is blank; no logos or information of any type is displayed on the browser when I attempt accessing these sites. However youtube works just fine without a problem. When I initially set up the server I had to edit the Apache program on my computer server to allow access. Thats when everything started working correctly except for the display screw up on social media sites. Any ideas on how to make the damn thing display would be graciously accepted lol. for the life of me ive tried screwing with everything and even different phproxy programs. Thanks! ~~This kid P.s my OS is Widows 7 and ive tried on multiple browsers. also if yall have questions on info that ive provided, or havent, please dont hesitate to ask.
  2. Hi, I am a PHP noob. I have a table in which I am showing data from a mysql database. I'm using PDO to do the database stuff. Thus far, all good. In the table I have a hidden field that stores my unique identifier for that row. Each row in the table has an 'Edit' button. I am showing the row in a DataTable. I am displaying the data using form text elements so I can make it editable in place. I have all that working. The problem 'I think' is that the form elements in every row have the same name as in every other row. If I show a single record I can change something and click edit and it works fine. If I fill the table with records, then change something in a row and click edit, it doesn't work. I have tried to concatenate an index number onto the names of each field, thus making them all unique, but it still isn't working. Here is some code: try { if(isset($_POST['update'])){ $updatedQuery = "UPDATE fac_detail SET first_name=:fname, last_name=:lname, height=:height ,cap=:cap,colors=:color WHERE employee_id=:hidden"; $stmt = $dbh->prepare($updatedQuery); $stmt->bindParam(':fname', $_POST['firstName'], PDO::PARAM_STR); $stmt->bindParam(':lname', $_POST['lastName'], PDO::PARAM_STR); $stmt->bindParam(':height', $_POST['height'], PDO::PARAM_STR); $stmt->bindParam(':cap', $_POST['cap'], PDO::PARAM_STR); $stmt->bindParam(':color', $_POST['color'], PDO::PARAM_STR); $stmt->bindParam(':hidden', $_POST['hidden'], PDO::PARAM_STR); $stmt->execute(); } $sql = "SELECT * FROM fac_detail"; $stmt = $dbh->prepare($sql); $stmt->execute(); $arrValues = $stmt->fetchAll(PDO::FETCH_ASSOC); $row = $stmt->fetch(); } catch(PDOException $e) { die($e->getMessage()); } echo "<form action=facultyPage.php method= post>"; echo '<table id="recordTable">'; echo '<thead>'; echo '<tr>'; echo "<th>First Name"; echo "<th>Last Name"; echo "<th>Height</th>"; echo "<th>Cap</th>"; echo "<th>Color</th>"; echo "<th>Editable BUTONNNS</th>"; echo '</tr>'; echo '</thead>'; echo '<tbody>'; $num = 0; foreach ($arrValues as $row){ echo "<tr>"; echo "<td>" . "<input type=text name=firstName value=" . $row['first_name'] . " </ td>"; echo "<td>" . "<input type=text name=lastName value=" . $row['last_name'] . " </ td>"; echo "<td>" . "<input type=text name=height value=" . $row['height'] . " </ td>"; echo "<td>" . "<input type=text name=cap value=" . $row['cap'] . " </ td>"; echo "<td>" . "<input type=text name=color value=" . $row['colors'] . " </ td>"; echo "<td>" . "<input type=hidden name=hidden value='" . $row['employee_id'] . "' /> "; //TODO dropdowns //echo '<td><select name="degree"></td>'; //echo ' <option></option>'; //echo ' <option></option>'; //echo '</select> '; //echo '<td><select name="school" disabled="disabled"></td>'; //echo '<option></option>'; //echo '<option></option>'; //echo '</select>'; echo '<input type="submit" name= "update" value="Update" /></td>'; echo '</tr>'; $num++; } echo '</tbody>'; echo '</table>'; echo "</form>"; I am showing it in a datable, I have that working fine. Each rows form elements have the same names. I think thats where the problem lies. Anyone know an approach or trick I can implement so the submit button knows which row it's on? Thanks in advance...
  3. I need a domain example.com redirects to sub-domain a.example.com when I type on the address bar. <script type="text/javascript"> $(function(){ var city = readCookie('city'); if(city==null && city==''){ window.location.href = 'http://' + city + '.example.com'; } $('#citygo').change(function(){ var city = $(this).val(); createCookie('city', city, 28); window.location.href = 'http://' + city + '.example.com'; }); }); </script> <body> <select id="citygo"> <option value="0">Select City</option> <option value="amsterdam">Amsterdam</option> <option value="newyork">New York</option> <option value="london">London</option> <option value="cardiff">Cardiff</option> </select> </body> The cookie on the server side is not holding so the domain cannot remember sub-domain. What am i doing wrong? Any help will be very much appreciated. <?php $hour = time() + 50400; //Time you want the cookie to last, currently 14 hours setcookie(My_Site_Location, $_SERVER['citygo'], $hour, '/', 'example.com'); if (isset($_SERVER['citygo'])) { $cookies = explode(';', $_SERVER['citygo']); foreach ($cookies as $cookie) { list($cookie_id, $cookie_value) = explode('=', $cookie); if($cookie_id === $name){ self::set_cookie($cookie_id, $value, $expiry, $path, $domain); } } } ?>
  4. Hi all GURU's, I have a problem with UTF-8 characters when I post values/data from my MySQL database into the OPTIONs that I use when using a SELECT in my FORM. The PHP script files are in format UTF-8. The database, the tables and the columns are all set in UTF-8. The charset in the META-tag for the html output is set to UTF-8. All other text that is fetched from the database shows my characters (Swedish å ä ö) the right and correct way, EXCEPT when I echo the data in the OPTIONs in my SELECT box. What can I do? Sincerely, Andreas
  5. Hello, I am querying a Mysql Database and displaying the results in a table. I need the results to Group twice and show totals. What I need is the results to group by the employee name, then under that name group by the date field. Then at the end of each date total up four of the columns that contain numbers. So the output would look like this: Employee Name Date Description Job Activity Comments Hours OT Travel OT XXXX XXXXX XXXXXX XXXXXX 3 2 1 1 XXXX XXXXX XXXXXX XXXXXX 2 0 0 1 XXXX XXXXX XXXXXX XXXXXX 1 0 1 1 Totals 6 2 2 3 Date Description Job Activity Comments Hours OT Travel OT XXXX XXXXX XXXXXX XXXXXX 3 2 1 1 XXXX XXXXX XXXXXX XXXXXX 2 0 0 1 XXXX XXXXX XXXXXX XXXXXX 1 0 1 1 Totals 6 2 2 3 Date Description Job Activity Comments Hours OT Travel OT XXXX XXXXX XXXXXX XXXXXX 3 2 1 1 XXXX XXXXX XXXXXX XXXXXX 2 0 0 1 XXXX XXXXX XXXXXX XXXXXX 1 0 1 1 Totals 6 2 2 3 Employee Name Date Description Job Activity Comments Hours OT Travel OT XXXX XXXXX XXXXXX XXXXXX 3 2 1 1 XXXX XXXXX XXXXXX XXXXXX 2 0 0 1 XXXX XXXXX XXXXXX XXXXXX 1 0 1 1 Totals 6 2 2 3 Date Description Job Activity Comments Hours OT Travel OT XXXX XXXXX XXXXXX XXXXXX 3 2 1 1 XXXX XXXXX XXXXXX XXXXXX 2 0 0 1 XXXX XXXXX XXXXXX XXXXXX 1 0 1 1 Totals 6 2 2 3 etc.... My code so far, I can not figure how to do the second grouping by date and put the totals in. mysql_select_db("time", $con); $result = mysql_query("SELECT * FROM data WHERE labor_date BETWEEN '$start' AND '$end' Group By user_name, labor_date Order by last_name ASC"); if (mysql_num_rows($result)==0) { echo "[warning_box]There are not any hours recorded for the time period that you chose. Please try again with a different set of dates.[/warning_box] "; } else { $current_user_name = false; while($row = mysql_fetch_array($result)) { // listing a new employee? Output the heading, start the table if ($row['user_name'] != $current_user_name) { if ($current_user_name !== false) echo '</table>'; echo '[divider_padding]';// if we're changing employee, close the table echo ' <h5>'.$row['last_name'].', '.$row['first_name'].'</h5>[minimal_table] <table> <tr> <th style="width:200px">Description</th> <th style="width:75px" class="tableleft">Job</th> <th style="width:75px" class="tableleft">Activity</th> <th style="width:290px" class="tableleft">Comments</th> <th style="width:64px" class="tableright">Hours</th> <th style="width:64px" class="tableright">OT</th> <th style="width:64px" class="tableright">Travel</th> <th style="width:63px" class="tableright">TOT</th> </tr>' ; $current_user_name = $row['user_name']; } // output the row of data echo '<tr> <td>'.$row['description'].'</td> <td class="tableleft">'.strtoupper($row['job']).'</td> <td class="tableleft">'.$row['activity'].'</td> <td class="tableleft">'.$row['comments'].'</td> <td class="tableright">'.$row['rthours'].'</td> <td class="tableright">'.$row['othours'].'</td> <td class="tableright">'.$row['trthours'].'</td> <td class="tableright">'.$row['tothours'].'</td> </tr> '; } echo '</table>[/minimal_table]'; // close the final table I am really stuck, Any help would be greatly appreciated!!!!
  6. hi i was just wondering how i would go about keeping user input in a field if an error occurs e.g. if i accidentally type in a special character into my form it will display a message saying : is not aloud or something like that but once this is shown all user input is lost so they would have to type it in again, ive tryed going online and i cant seem to find anything that works as it comes up with undifiened index <input type="text" name="clientname" value="<?php echo htmlspecialchars($_post['clientname']);?> > aswell as this im really in need of a message that says success, ive got no clue how i would go about doing it. what i need is a message that says 'form submitted'once you press submit and when no errors occur. greatly apreciate anyone that can help
  7. hopefully this will be the end of this little project but ive been trying to do this for a while now i need to get 2 different collumns one of which is hidden which will be the ID one has the value of the field e.g. test, im hopefully down to the last error. ( ! ) Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in C:\wamp\www\AddLeads\addeadstemplate.php on line 254 Call Stack # Time Memory Function Location 1 0.0000 186408 {main}( ) ..\addeadstemplate.php:0 2 0.0156 194880 mysqli_fetch_row ( ) ..\addeadstemplate.php:254 <tr> <td>Type of Business:</td> <td> <select name="typeofbusiness"> <option value=''> - select type of business -</option> <?php $sql = "SELECT tbl_typesofbusiness.id, tbl_typesofbusiness.Agent FROM tbl_typesofbusiness"; $res = mysqli_query($con, $sql) or (mysqli_error($con)); while (list($id, $tob) = mysqli_fetch_row($res)); { echo "<option value='$id'>$tob</option>\n"; } ?> </select> </td> <td><span class="error">* <?php if (isset($errors['typeofbusiness'])) echo $errors['typeofbusiness']; ?></span></td> </tr> i can get rid of the error bie adding 'or die' on line 253 other than just or but what this does is stop everything under or die stops working cause ive got another 6 or 7 fields under type of business aswell as this no error occurs so im confused to hell, hopefully its not to complicated any help will be greatly appreciated
  8. i am creating a timesheet in php , i need a logic to update the database , the working is as follows 1. accept employee_id and date , from date get week number , query database with this input as follows my database task3 contains and id , emp_id , p_name , time , taskdate mysql_query("SELECT p_name, SUM(IF(DAYOFWEEK(taskdate) = 2, `time`, 0)) AS `MO`, SUM(IF(DAYOFWEEK(taskdate) = 3, `time`, 0)) AS `TU`, SUM(IF(DAYOFWEEK(taskdate) = 4, `time`, 0)) AS `WE`, SUM(IF(DAYOFWEEK(taskdate) = 5, `time`, 0)) AS `TH`, SUM(IF(DAYOFWEEK(taskdate) = 6, `time`, 0)) AS `FR`, SUM(IF(DAYOFWEEK(taskdate) = 7, `time`, 0)) AS `SA`, SUM(IF(DAYOFWEEK(taskdate) = 1, `time`, 0)) AS `SU` FROM task3 WHERE e_id = '$r' AND WEEK(`taskdate`,-1) ='$week' GROUP BY p_name "); this is returned through ajax onto my page , and then i can change date and get the result ,(check the attachments) i want to update the textboxes , this is my issue , i need a logic to get left-mist coloumn project_name and top coloumn date . table is created in php , with textboxes and values set to those coming from database ,
  9. I have the following code which works just fine sending the $xml. However when i try to add a file to be sent with the xml as well i get an error. I tried using a postData array but then got an array to string error. The way i have it now works but it only sends the xml not the file. Any ideas on how I can send the @file with the postfields? Any help is appreciated $header = array('Content-Type: multipart/form-data'); $xml['xml'] = '<UploadPhoto>'; $xml['xml'] .= '<ID>12345</ID>'; $xml['xml'] .= '<PhotoID>myphoto</PhotoID>'; $xml['xml'] .= '<Filename>myphoto.jpg</Filename>'; $xml['xml'] .= '<Instructions>Need cheeks less rosy</Instructions>'; $xml['xml'] .= '</UploadPhoto>'; $postData = array( 'file' => '@/myphoto.jpg', 'xml' => $xml ); } $connection = curl_init(); curl_setopt($connection, CURLOPT_URL, "http://www.myurl.com/api"); curl_setopt($connection, CURLOPT_HTTPHEADER, $header); curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($connection, CURLOPT_POST, 1); curl_setopt($connection, CURLOPT_POSTFIELDS, $xml); curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1); set_time_limit(108000); $output = curl_exec($connection); curl_close($connection); print_r($output);
  10. Okay, here is the required information: Apache/2.2.22 (Ubuntu) MySQL client version: 5.5.34 PHP extension: mysqli Here are the three raw sql statements, using sample data. Statement 1: SELECT uuid FROM EmptyCart WHERE uuid = '52b6392b-c55f-71ef-2437-c0645d3d5ea0' Statement 2: UPDATE EmptyCart SET fname="so", lname="this", company="should", address="insert", city="", state="", zip="", phone="", country="US", cart_coupon="", email="", orderSubTotal="46.15", orderTotal="46.15", numOfItems="2", items="a:2:{i:0;s:5:item1;i:1;s:5:item2;}", ids="a:2:{i:0;s:3:id1;i:1;s:3:id2;}", codes="a:2:{i:0;s:5:code1;i:1;s:5:code2;}", qtys="a:2:{i:0;s:1:1;i:1;s:1:1;}", price="a:2:{i:0;s:5:44.95;i:1;s:3:1.2;}", orderTax="0", orderShipping="0", appliedPromoIdList="", coupon="", storeId="storeid", activeShipPromotionCount="", itemImages="a:2:{i:0;s:6:image1;i:1;s:6:image2;}", date="Mon Dec 02 2013 13:40:38 GMT-0500 (Eastern Standard Time)" WHERE uuid='52b6392b-c55f-71ef-2437-c0645d3d5ea0' Statement 3: INSERT INTO EmptyCart (uuid,fname,lname,company,address,city,state,zip,phone,country,cart_coupon,email,orderSubTotal,orderTotal,numOfItems,items,ids,codes,qtys,price,orderTax,orderShipping,appliedPromoIdList,coupon,storeId,activeShipPromotionCount,itemImages,date) VALUES ("52b6392b-c55f-71ef-2437-c0645d3d5ea0","so","this","should","insert","","","","","US","","","46.15","46.15","2","a:2:{i:0;s:5:item1;i:1;s:5:item2;}","a:2:{i:0;s:3:id1;i:1;s:3:id2;}","a:2:{i:0;s:5:code1;i:1;s:5:code2;}","a:2:{i:0;s:1:1;i:1;s:1:1;}","a:2:{i:0;s:5:44.95;i:1;s:3:1.2;}","0","0","","","storeid","","a:2:{i:0;s:6:image1;i:1;s:6:image2;}","Mon Dec 02 2013 13:40:38 GMT-0500 (Eastern Standard Time)") No errors are being returned, in fact, the queries all work fine. What is happening is actually within the PHP, however I have included the SQL statements as they may be causing the logic errors in the PHP code operation. Here is the section of PHP code where the error is happening: mysqli_select_db($con,$mysql_database); $prequery = mysqli_query($con,"SELECT uuid FROM ".$mysql_table." WHERE uuid = '".$tablevalues[0]."'"); $tango = $prequery->fetch_assoc(); if ($tango["uuid"]=$tablevalues[0]) { $new_count = count($tablefields); $mysql_update = ""; for ($z=1;$z<$new_count-1;$z++){ $mysql_update .= $tablefields[$z]."=".$tablevalues[$z].", "; } $mysql_update .= $tablefields[27]."=".$tablevalues[27]; $sql = "UPDATE ".$mysql_table." SET ".$mysql_update." WHERE uuid='".$tango["uuid"]."'"; } else { $sql = "INSERT INTO {$mysql_table} ({$tablefields_implode}) VALUES ({$tablevalues_implode})"; } // pprint_r($sql); mysqli_query($con,$sql); mysqli_close($con); The Correct Functionality should be: On the client-side, a new user visits the page the form resides on and begins filling out the form. Upon initial visit, a unique identifier is assigned to the user and stored in localstorage. Every time a form field is updated/changed the value is stored in localstorage. Every 30 seconds, selected contents of the form data (as pulled from localstorage) are sent to our server database via Ajax POST. The PHP Processing file receives the POST data and performs a series of SQL injection prevention functions on the data. The PHP file constructs a new array of cleaned data and uses that data array to construct the mysqli queries above. What should happen is the unique identifier should be checked against existing database entries and if it exists the relevant entry should be updated. If the unique identifier does not exist, a new entry is made. What is currently happening: Every incoming POST is evaluated and results in an UPDATE statement, even if the unique identifier does not exist in the database. Things I have tried: I have tried changing the value of the request for $prequery to reference a variable established earlier in the processing, but the result was the same. The code selects from the database and is still somehow evaluating that nothing = something. Notes: The first SQL statement, the select one, is the reason for the change of the variable to one earlier in the array processing. The value of the variable was being displayed with double quotes around it and breaking the SQL statement, however even with the new variable that does not have the double quotes the operation is still resulting in an Update instead of Insert despite the uuid not being in the database.
  11. Hello, I've been working on my company site (Wordpress based) on XAMPP, which managed to get confused with the live site (my bad, I didn't update all the links). From the files I downloaded, I am no getting the following error when loading the site - I haven't changed anything in this file, so I'm baffled as to what has happened! line 137 is - $pinfos= get_group ('Page-Info',762); //print_r($pinfos); Any ideas?! I'm new to php, so finding this very trying!!! Many thanks
  12. right what i need to do is create 2 collumns for a html form, one of these is the ID and needs to be hidden and one collumn is full of options associated with these ID's the table which these two collumns are located on the database is called tbl_typesofbusiness and i just cant figure this out ive got the option box up but thats as far as i got i cant get two collumns up and they is no options in the option box, i just cant hack it ive been trying for a while and im confused to hell. <tr> <td>Type of Business:</td><td> <select name="typeofbusiness"> <?php $sql = sprintf("SELECT tbl_typesofbusiness.id, tbl_typesofbusiness.Agent FROM tbl_typesofbusiness")?></td> <td><span class="error">* <?php if (isset($errors['typeofbusiness'])) echo $errors['typeofbusiness']; ?></span></td> </tr> they is no errors on this code but i still cant seem to find a solution to it aswell theres only one record in the table at the moment which is called test1 with an id of 1. please help i just cant seem to hack it.
  13. kwmlr439

    New to PHP

    I have created some tables on phpmyadmin but not sure if I did it right regarding varchar and the 255 value. If anyone is familiar with this and can correct it that would be great. Thanks. Here are the tables: http://oi44.tinypic.com/1z6v2j5.jpg
  14. Hi, I am newbie for PHP and MySQL I found this error, please help me. Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\Shopping\products.php on line 39 Here the full coding: <?php include("includes/db.php"); include("includes/functions.php"); error_reporting (E_ALL ^ E_NOTICE); if($_REQUEST['command']=='add' && $_REQUEST['productid']>0) { $pid=$_REQUEST['productid']; addtocart($pid,1); header("location:shoppingcart.php"); exit(); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Products</title> <script language="javascript"> function addtocart(pid){ document.form1.productid.value=pid; document.form1.command.value='add'; document.form1.submit(); } </script> </head> <body> <form name="form1"> <input type="hidden" name="productid" /> <input type="hidden" name="command" /> </form> <div align="center"> <h1 align="center">Products</h1> <table border="0" cellpadding="2px" width="600px"> <?php $result=mysql_query("select * from products"); while($row=mysql_fetch_array($result)){extract($row); ?> <tr> <td><img src="<?php echo $row['picture']?>" /></td> <td> <b><?php echo $row['name']?></b><br /> <?php echo $row['description']?><br /> Price:<big style="color:green"> RM<?php echo $row['price']?></big><br /><br /> <input type="button" value="Add to Cart" onclick="addtocart(<?php echo $row['serial']?>)" /> </td> </tr> <tr><td colspan="2"><hr size="1" /></td> <?php } ?> </table> </div> </body> </html>
  15. how to display the textarea content from database using ckeditor. i did it with php as below and it works perfect but how to do same in ckeditor.Any idea.......: <html> <head> //<script src="../ckeditor.js"></script> </head> <?php $conn=mysql_connect("localhost","root","")or die(mysql_error()); mysql_select_db("regis")or die(mysql_error()); print_r($_GET); $p_id=$_GET['p_id']; $query=mysql_query("SELECT p_content FROM admin_page WHERE p_id='$p_id'")or die(mysql_error()); $row=mysql_fetch_array($query,MYSQL_ASSOC); print_r ($row['p_content']); ?> </html>
  16. If ANyone uses CK editor then plz help me i m in great trouble.i download ck editor from the site and after unzip the folder paste all the files where my PHP files are.But can't find how to use it.any help is greatly appreciated.
  17. how to update a database field considering a specific amount of values. the code i Know is this is to update a specific value UPDATE `users` SET `user_level`=1 WHERE `user_id`=7 and this is to update a particular field UPDATE `users` SET `user_level`=1; but the code for a range of values in a field using the id as the range say where id=7 to 35, i don't know the code
  18. Hello, I have been starded using redbean. I have a really big table and want to select 5000 rows at time using redbean! I want only the rows where the field "status" IS NULL This is my code: $min = R::$c->begin()->addSQL('SELECT MIN(id)')->from('emailtable')->get('cell'); $max = R::$c->begin()->addSQL('SELECT MAX(id)')->from('emailtable')->get('cell'); for ($i = $min; $i < $max; $i = $i + 5000) { $x = $i; $y = $i + 5000; $select = R::$c->begin() ->addSQL(' SELECT * ') ->from('emailtable') ->where(" id >= ? AND id < ? AND status IS NULL ") ->put($x) ->put($y) ->get(); } Anyone know if this is the right way to go! Should i use: id >= ? AND id < ? AND status IS NULL or maybe i should use BETWEEN but not sure. My problem is The code above is sometimes selecting same id twice and that is what i do not expect! there for i ask if there is a other solution four the code above! All ides are welcome. It is really hard to find information about redbean/chunk/select/ example
  19. Hi, I am having a bit of a problem with a simple task and I was wondering if someone would be able to help. I have a php system which allows members to sign up, stores their information in a mysql database, then they can sign in and do all sorts of things. The area I have a problem with is I'm trying to make an update page so that they can edit their details stored in the mysql database. My code is as follows. <?php session_start(); include_once "base.php"; //connects to database $username = mysql_real_escape_string($_SESSION['Username']); // get users username from session $forename = mysqL_real_escape_string($_SESSION['Forename']; //gets already stored forename $newforename = mysql_real_escape_string($_POST['newforename']);//post for new forename $registerquery = mysql_query("INSERT INTO users WHERE Username = '".$username."'(Forename) VALUES('".$newforename."')"); //finds row for the user and updates the forename column with new record ?> <form method="post" action="index.php" name="registerform" id="registerform"> <fieldset> <label for="newforename">Forename:</label><input type="text" name="newforename" id="newforename" /><br /> <input type="submit" name="register" id="register" value="Register" /> </fieldset> </form> Unfortunately this code does not update the database at all, however it does not crash or produce any errors! I would really appreciate any help you can give with this.
  20. I'm adding a piece of functionality to an existing SAML login plugin for the "owncloud" cloud storage application https://github.com/owncloud/apps/tree/master/user_saml Within the lib/ directory of this plugin there is a hook class (hooks.php) which extracts SAML attributes and creates a user account based on this info. It currently expects email and name to be available to populate the user account details, which are not available in most identity providers. I'd like to provide a form that when a new user logs in, they can submit the personal information rather than have blank info be given by SAML. At line 83 in this hooks.php file (available at the link above), i'd like to call a page or function that would present a form to the user (with three fields - firstname, surname and email), then on submit, return to the hook class making the three variables available to the rest of the hooks class code. Since this hooks file is a 'processing' PHP file rather than a page that is rendering anything, and also part of the owncloud framework's workings, I don't think this can be done with just PHP and probably a combination of javascript/ajax might be needed. Doesn anyone have an opinion on a solution to this, i.e. being able to move out of a hook class to provide a user interactive form, then continue from the place where the hook class was - utilising the fields the user provided?
  21. I have a script that is not own Originally this written in PHP5 and a little in getting the session value am going to write paste all login.php <?php session_start(); $error_page = "index.php?error="; $success_page = "../main/log.php"; define("PPDIA_APP", 1); require_once "../models/db.php"; require_once "../models/loginModel.php"; require_once "../models/sessionModel.php"; //Create a new instance of the loginHandler $login = new loginModel(); $login->setDebug(); $login->setCredentials($_POST['username'], $_POST['card_pin']); //Authenticate user $logged_in = $login->authenticateUser(); if( $logged_in ) { sessionModel::init(); sessionModel::setParam("user", $login->getDetails()); $location = $success_page; } else { $error_page .= "Your username and pin combination is invalid"; $location = $error_page; } exit(); header("Location: {$location}#!/page_jamb utme"); ?> Next is sessionModel.php <?php class sessionModel { public static $session_id = "9jsschoo_php_app"; public static function init() { session_start(); $_SESSION[sessionModel::$session_id] = new stdClass(); } public static function setParam($param, $data) { $_SESSION[sessionModel::$session_id]->$param = $data; } public static function resetParam($param) { unset( $_SESSION[sessionModel::$session_id]->$param ); } public static function getParam($param) { return $_SESSION[sessionModel::$session_id]->$param; } } Next is loginModel.php <?php class loginModel extends db { private $credentials; private $enc_pass; private $details; function loginModel() { parent::__construct(); $credentials = new stdClass(); } function setCredentials($username, $password) { $this->credentials->username = $username; $this->credentials->password = $password; $this->enc_pass = $this->encryptPass($password); } function authenticateUser() { $check = $this->fetchData("", "#__users", "username", $this->credentials->username, "password", $this->enc_pass); if( !empty($check) ) { $this->details = (object) $check[0]; return true; } else { return false; } } function getDetails() { return $this->details; } } This Last One Is Not Important db.php <?php //No direct Access defined("PPDIA_APP") or die("Restricted Access"); class db { private $ppdia_conn, $db_res, $md_pass, $db_name; private $table_prefix, $limit; function db() { $this->table_prefix = ""; $this->ppdia_conn = new mysqli( "localhost", "root", "", "skul_solution" ) or die ( "error" ); } function setPrefix($pref) { $this->table_prefix = $pref; } function getResult() { return $this->ppdia_conn; } function setDebug() { $this->debug = true; } function getDebug( $input ) { if( $this->debug ) { print "<div style='background-color: white; color: red;'><hr />"; if( is_array($input) || is_object($input) ) print "<pre>" . print_r( $input, 1 ) . "</pre>"; else print $input; print "<hr /></div>"; } } function myarray( $array ) { print "<pre>"; print_r( $array); print "</pre>"; } function prepareInput( $input ) { if( is_array( $input ) && !empty( $input ) ) { $keys = array_keys( $input ); foreach( $input as $i ) { $k = $keys[$x]; $prepared = $prepared = $this->prepareString($i); $input[$k] = $prepared; $x++; } } else if( is_string( $input ) ) { $input = $this->prepareString($input); } return $input; } function prepareString($string) { $prepared = $this->ppdia_conn->real_escape_string( stripslashes($string) ); return $prepared; } function encryptPass( $pass ) { $spice = 'p0pSyPeD1A_5p1cypa55'; $site_name = "9jaschool_php"; $hash = md5( "Password: " . $pass . $site_name . $spice ); $mdpass = substr( $hash, 0, 17 ) . ":" . substr( $hash, 17, 33 ); //echo $mdpass; $this->getDebug( "<p>" . $mdpass . "</p>" ); /* * For PHP >= 5.5.0 * $mdpass = apps::encryptString($pass); */ //echo $pass . " is " . $mdpass; return $mdpass; } function insertInto( $table, $rows, $values ) { $table = $this->getTable($table); if( is_string($rows) ) $rows = explode( ",", $rows ); if( is_string($values) ) $values = explode( ",", $values ); if( is_array($values) && is_array($rows) && !empty( $values ) ) { $x = 0; $c = count($values); foreach( $values as $v ) { $r = $rows[$x]; if( $v && $r ) $nuval_arr[] = "`". $r . "`='" . $this->prepareString($v) . "' "; else $nuval_arr[] = "`". $r . "`='' "; $x++; } $val = implode(", ", $nuval_arr); } $value_set = $val; $sql_query = "INSERT INTO `" . $table . "` SET " . $value_set; $cm = $this->ppdia_conn; $this->getDebug( $sql_query ); //Insert the data into the database.... $queried = $cm->query( $sql_query ); if( $queried ) { $this->getDebug($cm->insert_id); return $cm->insert_id; } else { return false; } } function updateData( $type='string', $tab_name, $row, $data, $key1='', $value1='', $key2=NULL, $value2=NULL, $no_queries=5, $switch=1 ) { $tab_name = $this->getTable($tab_name); $cm = $this->ppdia_conn; if ( $type=='string' ) { if( !$key2 ) $reg_q = "UPDATE `" . $tab_name. "` SET `" . $row . "` = '" . $data . "' WHERE `" . $key1 . "` = '" . $value1 . "';"; else $reg_q = "UPDATE `" . $tab_name. "` SET `" . $row . "` = '" . $data . "' WHERE `" . $key1 . "` = '" . $value1 . "' AND `" . $key2 . "` = '" . $value2 . "';"; } else { foreach( $row as $ro ) $db_row[] = $ro; foreach( $data as $d ) $udata[] = $d; //print "<pre>"; print_r($udata); print"</pre>"; $x = 0; foreach( $db_row as $key=>$r ) { $sets[] = "`" . $r . "` = '" . $udata[$x] . "'"; $x++; } if( !$key2 ) $where = "WHERE `" . $key1 . "` = '" . $value1 . "';"; else $where = "WHERE `" . $key1 . "` = '" . $value1 . "' AND `" . $key2 . "` = '" . $value2 . "';"; $reg_q = "UPDATE `" . $tab_name. "` SET " . implode(", ", $sets) . " " . $where; } $this->getDebug($reg_q); $reg = $cm->query( $reg_q ); $res = $reg->affected_rows; return $res; } function checkDb() { if ( !$this->ppdia_conn ) return "Could Not Connect to The Database"; else return true; } function getType($data) { if( !is_numeric($data) ) $data = "'" . $data . "'"; return $data; } function getTable($tname) { return str_replace( "#__", $this->table_prefix, $tname ); } function getTableCols($table) { $table_name = $this->getTable($table); $sql = "SELECT table_name, column_name, data_type, data_length FROM USER_TAB_COLUMNS WHERE table_name = '" . $table_name . "';"; //Mysql specific.. $sql = "SHOW FIELDS FROM `" . $table_name . "`;"; return $this->customQuery($sql); } function setLimit($start, $length) { $this->limit = " LIMIT {$start}, {$length} "; } function fetchData( $data, $t_name, $row1=NULL, $rowdata1=NULL, $row2=NULL, $rowdata2=NULL, $switch=1 ) //fetch all data from a table. { $cm = $this->ppdia_conn; $t_name = $this->getTable($t_name); $rowdata1 = $this->getType($rowdata1); $rowdata2 = $this->getType($rowdata2); if ( !$data ) $data = '*'; if( !$row1 ) $sql = "SELECT " . $data . " FROM `" . $t_name . "`{$this->limit};"; else if ( !$row2 ) $sql = "SELECT " . $data . " FROM `" . $t_name . "` WHERE `" . $row1 . "`=" . $rowdata1 . "{$this->limit};"; else $sql = "SELECT " . $data . " FROM `" . $t_name . "` WHERE `" . $row1 . "`=" . $rowdata1 . " AND `" . $row2 . "`=" . $rowdata2 . "{$this->limit};"; $this->getDebug( $sql ); $result = $cm->query( $sql ); if($result) while( $res = $result->fetch_assoc() ) { $rawdata = $res; if( !empty($rawdata) ) { $output[] = $rawdata; } } if( !$switch ) $result->close; $this->getDebug( $output ); return $output; } function customQuery( $sql, $switch=1 ) { $cm = $this->ppdia_conn; $sql = $this->getTable($sql); $this->getDebug( $sql ); $result = $cm->query( $sql ); if( $result && ( preg_match("/select/",strtolower($sql)) || preg_match('/show fields/',strtolower($sql)) ) ) { if( preg_match("/from/",strtolower($sql)) ) { $res = array(); while( @$res[] = $result->fetch_assoc() ) { $output = $res; } } } $this->getDebug( $output ); return $output; } function checkTable() { $result = $this->fetchData( "", $this->getTableName() ); if( $result ) return true; else return false; } function deleteData( $table, $key, $value ) { $table = $this->getTable($table); $sql = "DELETE FROM `" . $table . "` WHERE `" . $key . "`='" . $value . "'"; $this->getDebug( $sql ); $deleted = $this->ppdia_conn->query($sql); return $this->ppdia_conn->affected_rows; } } Thanks I Just want the session to use on another file that need session to work may be the file that need the session is below <?php // PHP Script Chat - coursesweb.net define('MAXROWS', 30); // Maximum number of rows registered for chat define('CHATLINK', 1); // allows links in texts (1), not allow (0) // Here create the rooms for chat // For more rooms, add lines with this syntax $chatrooms[] = 'room_name'; $chatrooms = array(); $chatrooms[] = 'English'; $chatrooms[] = 'Government'; $chatrooms[] = 'Economics'; $chatrooms[] = 'Commerce'; $chatrooms[] = 'C.R.K'; // password used to empty chat rooms after this page is accessed with ?mod=admin define('CADMPASS', 'adminpass'); /* For example, access in your browser http://domain/chatfiles/setchat.php?mod=admin */ // If you want than only the logged users to can add texts in chat, sets CHATADD to 0 // And sets $_SESSION['username'] with the session that your script uses to keep logged users define('CHATADD', 0); if(CHATADD !== 1) { if(isset($_SESSION["9jsschoo_php_app"])) define('CHATUSER', $_SESSION["9jsschoo_php_app"]);; } // Name of the directory in which are stored the TXT files for chat rooms define('CHATDIR', 'chattxt'); include('texts.php'); // file with the texts for different languages $lsite = $en_site; // Gets the language for site if(!headers_sent()) header('Content-type: text/html; charset=utf-8'); // header for utf-8 // include the class ChatSimple, and create objet from it include('class.ChatSimple.php'); $chatS = new ChatSimple($chatrooms); // if this page is accessed with mod=admin in URL, calls emptyChatRooms() method if(isset($_GET['mod']) && $_GET['mod'] == 'admin') $chatS->emptyChatRooms(); this is the part where i have to put the session if(isset($_SESSION[""])) define('CHATUSER', $_SESSION[""]);; files that i suppose to contain the session
  22. I've got this data. - - - - - - - - - - - - - | ID | content | - - - - - - - - - - - - - | 1 | Hand Some | - - - - - - - - - - - - - | 2 | Big Apple | - - - - - - - - - - - - - | 3 | Green Day | - - - - - - - - - - - - - If I search data by "Some Hand", then it must show "Hand Some" cause it is on the list. I've try LIKE "%variable%" but it since it still only search for specific keyword that will match the data on a field. Can you please give an idea on what is the best way to filter data with my example
  23. Hi - we have been using google code to host our open source projects till now and they get a lot of downloads too.. Google code is going to stop offering downloads starting Jan 2014 and we want an alternate. We have enough bandwidth to host the download our self... but just need some help finding out the right too. the most important thing is that we need to offer direct downloads to our zip files... most of the scripts we find online are really in a manner that the download has to be router through php. is there a script of function out there that can do this job for us?
  24. Hi there, basically someone gave me coding that brings up a dropdown menu from the mysql database, I can't get it to work, there's a few syntax errors and the dropdown list won't come up, anyone have any ideas? Any help would be greatly appreciated! The coding is below (it wouldn't let me upload it as a file :S ) http://pastebin.com/xRDdcinf
  25. My table description is as follows **entry_table** - serial(int) - s_name(varchar) - user_id(int) - id(int) **Students_details** - id(int) - user_id(int) - student_name(varchar) - adress(varchar) **User_login** - user_id(int) - user_name(varchar) - password(varchar) - alotment(bool) Scenario is that the students apply for multiple scholarships. Their selections are stored in the entry_table's s_name, user_id and id fields. My next step is to build a sorted list of all the students who applied for a particular scholarship eg:"scholarship1". This list should also show the student's name(student_name field of the students_details table) The lists are to be sorted according to two types of scholarships that the system offers(merit and need). Applicants of the merit scholarship are required to be sorted in descending order using the ratio(obtained marks/ total marks). However, the need scholarship is to be shorted in ascending order as it uses the ratio(family income/no. of non-earning family members) I tried to join my tables using $query = "SELECT *FROM entry_table, students_details WHERE entry_table.id=students_details.id group by entry.s_id,entry.student_id"; Please help in the sorting as per type problem. Also the above query helps joining the tables but doesnt achieve the purpose. thanking you in advance
×
×
  • 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.