Jump to content

Search the Community

Showing results for tags 'mysql'.

  • 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. Hellow, i need help please, writing code and it doesn't work. please help... Here it is WHERE start_date BETWEEN 'start_date".strtotime('-3 day')."' AND 'start_date'"; without this code everithing works fine Thank you
  2. Hello every body.... I'm creating a simple php project where the user will be able to choose option from dropdown menu and the query will be executed accordingly.. The html form is shown below.... <select name='movie_name'> <option value='ALL'>All</option> <option value='blah'>Blah blah </option> <option value='blah'>Blah blah </option> ... </select> <select name='movie_genre'> <option value='ALL'>All</option> <option value='Horror'>Horror</option> <option value='Anime'>Anime</option> ... </select> <select name='movie_cast'> <option value='ALL'>All</option> <option value='john'>john</option> <option value='Katrina'>Blah blah Katrina</option> ... </select> If the user select "ALL" then, all the resuls will be displayed according to the selected options AND again If the user select "different" options then, all the resuls matcing from the database will be shown... Tha database schema is shown below | id | movie_name| movie_genre | movie_cast | 1 | Hello Brother | Comedy | Salman Khan | 2 | Blah blah | ALL | Blah blah | 3 | ALL | ALL | ALL | 4 | Blah Blah | Blah Blah | ALL * here "ALL" is a specific text which may or may not be present in the rows.... Thank u in advance....
  3. What I want to do is what is in the shown in the table. I want to only get the Math subject and order the units from unit 1 (UI) to the last available unit in the database; after this, under each unit, to show the homework related to each unit. I have tried to save it into an array with mysql_fetch_array but it stores the row that involves one unit. I want all the units and only the units with their homework under them. My database is attached to this post in a txt file. hope someone can help. <!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>Documento sin título</title> </head> <body> <form action="" method="post" name="form1" id="form1"> <table width="200" border="1"> <tr> <td>Subject:</td> <td>Math</td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td>UI</td> <td>UI</td> <td>UII</td> <td>UIII</td> <td>UII</td> <td>...</td> </tr> <tr> <td>Home work</td> <td>Math work1</td> <td>Math work2</td> <td>Math work3</td> <td>Math work4</td> <td>Math work5</td> <td>...</td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> </body> </html>
  4. Hi guys I need some help with slow connection to remote mysql database. I've been after this for a couple of days. I've been reading around but I didn't find any solution which helped me. I have this scenario: Server A e-commerce running mysql database running Server B e-commerce running remote connection to server A database The two e-commerce are identical. On server A it runs very quick, on server B the connection to mysql database it's about 16 times slower. Some complex queries and mixes queries don't get resolved and let the page go in timeout. I tried a test php script where I connect to mysql and I run a simple query (some classes are required before the query). On server A execution time is 0.107 seconds while on server B it is 1.788 seconds. I tried to have the same test with both firewall (server A and B) turned off but the results is exactly the same. I added in my.cnf of server A skip-name-resolve and restarted mysql but this didn't really change anything I am logging slow queries and none from server B are recorded in the file Running the same query from remote ssh connection from server B to server A's mysql is very fast Connection is set to persistent on server B's e-commerce Both server have centos 6.2 installed with WHM/Cpanel, configurations are basically the same. Do I miss something obvious?
  5. Hi all, I'm working on a project involving an orders set of APIs, and having trouble coming up with the best logic to handle this - with the smallest amount of overhead and client facing slowness. Here's the jist of what I'm looking at... There are 21 API methods to pull different types of orders, and each of them handle paging by requesting a number of records (10 - 500), and a page number. So I could say in my URI, "page-no=1&no-of-records=50", followed by "page-no=2&no-of-records=50", to get subsequent records. The API will return in each call the total records returned as well as the total records in their database. Now, I want to insert all of this into my database, and so that means something like 21 APIs * 3 SQL requests each = 63 sql queries (check it exists, if so update - else insert). This seems to me like way too much work for a client facing application. Any suggestions?
  6. Hello, I am new to this site and hope I am posting this in the right section... The thing is..... I would like some help with php and mysql.. What I want to create is a page where users can create an account by entering their name, email and password, and if the username is taken they will have to try again otherwise their details will be registered to the mysql table and have an account to login. Also I would like a redirect so if the user is a standard user it goes to say “home”, but if the user is an admin it will go to another page ie “home2”, and how would I create the admin in the same table on mysql or seperate? Right the last thing is once the user can register and login, so can the admin, for instance if there are 10 users, when logged in I want each of those users to see different information can this be done and how could I do this ? I thought maybe have the table and the id would be from 1-10 so if user is 1 being dan show his column, and if user logged 2 being steve show column id 2. Can somebody help me implement this please ? I am currently learning php and mysql, im in university I managed to learn how to create the table, connect login, search, add to the database when logged in and edit etc.. but for what I want to achieve now I cannot find any tutorials or help, could somebody please help me with the coding for this and what pages are what and how to create the table in mysql being either 1 table for both user and admin, or 2 tables for separate users and admin. Thanks for your help in advance guys
  7. I have one table but i try to make like the result not finished. Hmm.. can you see my table : I want to declare sum for parent kd_rekening in same row for "Anggaran" => jns_anggaran =1 and "Perubahan" => jns_anggaran = 2. And child ust load field nilai. Thanks before
  8. Hello everyone. I have a large table consisting of 135497 rows I have found that by indexing the table, it will take less time in quering the results. In some site it shows that Using "Explain" before the queries will show that how much rows it has to travel to get the desired results. SO I have doen and it shows like below... mysql> EXPLAIN select * FROM ip2country WHERE 3084727327 BETWEEN begin_long_ip AND end_long_ip; +----+-------------+------------+------+---------------------------------------------------------------------------------+------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+------------+------+---------------------------------------------------------------------------------+------+---------+------+--------+-------------+ | 1 | SIMPLE | ip2country | ALL | ip_adress,begin_long_ip,end_long_ip,begin_long_ip_3,count_index,begin_long_ip_2 | NULL | NULL | NULL | 135497 | Using where | +----+-------------+------------+------+---------------------------------------------------------------------------------+------+---------+------+--------+-------------+ The above results shows 135497. means it has to travel all the rows to get the result. So i have done index on the column ("begin_long_ip and end_long_ip) mysql> CREATE INDEX count_index ON ip2country(begin_long_ip,end_long_ip); Query OK, 135497 rows affected, 1 warning (0.87 sec) Records: 135497 Duplicates: 0 Warnings: 1 But it still shows the same result. mysql> EXPLAIN select * FROM ip2country WHERE 3084727327 BETWEEN begin_long_ip AND end_long_ip; +----+-------------+------------+------+---------------------------------------------------------------------------------+------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+------------+------+---------------------------------------------------------------------------------+------+---------+------+--------+-------------+ | 1 | SIMPLE | ip2country | ALL | ip_adress,begin_long_ip,end_long_ip,begin_long_ip_3,count_index,begin_long_ip_2 | NULL | NULL | NULL | 135497 | Using where | +----+-------------+------------+------+---------------------------------------------------------------------------------+------+---------+------+--------+-------------+ Ahy help will be greatly apprecaited...
  9. hello everybody I have a database of many rows out of which i have a column of mobile impression Which i've kept by serializing an array. The problem i'm facing is that i need to add the rows according to its key... My code The array structure is shown below Array ( [16/07/14] => Array ( [Vu] => 13 [No] => 49 [Al] => 45 [LG] => 69 ) Array ( [17/07/14] => Array ( [Vu] => 12 [No] => 3 [Al] => 5 [LG] => 1 ) ) The above array can be a very big array.... and it is dynamically fetched from database using a while loop. I want the output as Array ( [17/07/14] => Array ( [Vu] => 25 [No] => 52 [Al] => 50 [LG] => 70 ) ) The code i've used is while($row = $q->fetch(PDO::FETCH_ASSOC)) { $mob = unserialize($row['mobile_hits_received']); foreach ($mob as $value) { foreach($value as $key => $value1) { $final_mobile[$key] = $value[$value]+0; } } } Thank u in advance...
  10. I'm trying to display relevant user details when click after user details button.it is css pop up window.i want to know how to catch relevant user when click the button.my primary key is email. $connect = mysql_connect("localhost","root",""); if(!$connect){echo("<script>alert('DBMS connection error');</script>>");} if(!mysql_select_db("biz", $connect)){echo("<script>alert('Unable to find DB');</script>>");} $result1 = mysql_query("SELECT radio,yname,mail,cpw,tp,city FROM reg WHERE mail='SSS@SSS.SS'"); $row1 = mysql_fetch_assoc($result1); mysql_close($connect); <form class="form-signin" role="form"> User Type :Business Name : <?php echo $row1['yname'] ?> Email Address :abc@gmail.com Password :xxxxxx Telephone no :0777777777 </form> this is what i did.Now it's display same name(kasun) for every users details. please help.
  11. Hi, I'm trying to display a message first before redirect to other page, but my code just directly redirect the page without display the message.please help me. if($num_rows == 0) { echo '<script type="text/javascript">alert("Please Enter Correct Details!");</script>'; header ('Location :login.php'); }
  12. Hey guys been asking a bunch of my friends that know some php to try and help me with this issue im having with no success .. so i come here hoping to get answers i need. The delete function works but add and update dont work. <?php session_start(); require 'approve.php'; ?> <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Contacts</title> <!-- Include jQuery --> <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script> <style type='text/css'> body { background-color: #333; color: #999; font: 12px/1.4em Arial,sans-serif; } #wrap { margin: 10px auto; background: #666; padding: 10px; width: 1024px; } #header { background-color: #666; color: #FFF; } #logo { font-size: 30px; line-height: 40px; padding: 5px; } #navWrap { height: 30px; } #nav { padding: 5px; background: #999; } #nav ul { margin: 0; padding: 0; } #nav li { float: left; padding: 3px 8px; background-color: #FFF; margin: 0 10px 0 0; color: #F00; list-style-type: none; } #nav li a { color: #F00; text-decoration: none; } #nav li a:hover { text-decoration: underline; } br.clearLeft { clear: left; }​ </style> <script type='text/javascript'> //<![CDATA[ $(function() { // Stick the #nav to the top of the window var nav = $('#nav'); var navHomeY = nav.offset().top; var isFixed = false; var $w = $(window); $w.scroll(function() { var scrollTop = $w.scrollTop(); var shouldBeFixed = scrollTop > navHomeY; if (shouldBeFixed && !isFixed) { nav.css({ position: 'fixed', top: 0, left: nav.offset().left, width: nav.width() }); isFixed = true; } else if (!shouldBeFixed && isFixed) { nav.css({ position: 'static' }); isFixed = false; } }); }); //]]> </script> </head> <body> <div id="wrap"> <!-- The header code, including the menu --> <div id="header"> <div id="logo">Contacts<br /></div> <div id="navWrap"> <div id="nav"> <ul> <li><a href="#" class="smoothScroll"><a href="export.php">Export Contacts</a></a></li> </ul> <br class="clearLeft" /> </div> </div> </div> <?php $separate = ''; ini_set('display_errors', 'On'); ini_set("xdebug.var_display_max_depth", -1); ini_set("xdebug.var_display_max_children", -1); ini_set("xdebug.var_display_max_data", -1); $con = mysql_connect("66.150.xxx.xxx","contact","xxx"); if (!$con){ die("Can not connect: " . mysql_error()); } mysql_select_db("zadmin_contact",$con); if (isset($_POST['update'])){ $UpdateQuery = "UPDATE contact SET ID='$_POST[id]',Title='$_POST[title], First Name='$_POST[firstname]', Last Name='$_POST[lastname]', Company='$_POST[company]', Job Title='$_POST[jobtitle]', Business Phone='$_POST[businessphone]',Home Fax='$_POST[homefax]', Home Phone='$_POST[homephone]', Mobile Phone='$_POST[mobilephone]', E-mail Address='$_POST[email]' WHERE Name='$_POST[hidden]'"; mysql_query($UpdateQuery, $con); }; if (isset($_POST['delete'])){ $DeleteQuery = "DELETE FROM contact WHERE ID='$_POST[hidden]'"; mysql_query($DeleteQuery, $con); }; if (isset($_POST['add'])){ $AddQuery = "INSERT INTO contact (ID, Title, First Name, Last Name, Company, Job Title, Business Phone, Home Fax, Home Phone, Mobile Phone, E-mail Address) VALUES ('$_POST[uid]','$_POST[utitle]', '$_POST[ufirstname]', '$_POST[ulastname]', '$_POST[ucompany]', '$_POST[ujobtitle]', '$_POST[ubusinessphone]', '$_POST[uhomefax]', '$_POST[uhomephone]', '$_POST[umobilephone]', '$_POST[uemail]')"; mysql_query($AddQuery, $con); }; $sql = "SELECT * FROM contact"; $myData = mysql_query($sql,$con); echo "<table border=1 bgcolor=#FFFFFF align=center> <tr> <th>ID</th> <th>Title</th> <th>First Name</th> <th>Last Name</th> <th>Company</th> <th>Job Title</th> <th>Business Phone</th> <th>Home Fax</th> <th>Home Phone</th> <th>Mobile Phone</th> <th>E-mail Address</th> </tr>"; while ($record = mysql_fetch_array($myData)) { echo "<form action=\"dashboard.php\" method=\"post\">"; echo "<tr>"; echo "<td>" . "<input type=\"text\" name=\"id\" value=\"" . $record['ID'] . "\"> </td>"; echo "<td>" . "<input type=\"text\" name=\"title\" value=\"" . $record['Title'] . "\"> </td>"; echo "<td>" . "<input type=\"text\" name=\"firstname\" value=\"" . $record['First Name'] . "\"> </td>"; echo "<td>" . "<input type=\"text\" name=\"lastname\" value=\"" . $record['Last Name'] . "\"> </td>"; echo "<td>" . "<input type=\"text\" name=\"company\" value=\"" . $record['Company'] . "\"> </td>"; echo "<td>" . "<input type=\"text\" name=\"jobtitle\" value=\"" . $record['Job Title'] . "\"> </td>"; echo "<td>" . "<input type=\"text\" name=\"businessphone\" value=\"" . $record['Business Phone'] . "\"> </td>"; echo "<td>" . "<input type=\"text\" name=\"homefax\" value=\"" . $record['Home Fax'] . "\"> </td>"; echo "<td>" . "<input type=\"text\" name=\"homephone\" value=\"" . $record['Home Phone'] . "\"> </td>"; echo "<td>" . "<input type=\"text\" name=\"mobilephone\" value=\"" . $record['Mobile Phone'] . "\"> </td>"; echo "<td>" . "<input type=\"text\" name=\"email\" value=\"" . $record['E-mail Address'] . "\"> </td>"; echo "<input type=\"hidden\" name=\"hidden\" value=\"" . $record ['ID'] . "\">"; echo "<td>" . "<input type=\"submit\" name=\"update\" value=\"update\"> </td>"; echo "<td>" . "<input type=\"submit\" name=\"delete\" value=\"delete\"> </td>"; echo "</tr>"; echo "</form>"; } echo "<form action=\"dashboard.php\" method=\"post\">"; echo "<tr>"; echo "<td><input type=\"text\" placeholder=\"ID\" name=\"uid\"></td>"; echo "<td><input type=\"text\" placeholder=\"Title\" name=\"utitle\"></td>"; echo "<td><input type=\"text\" placeholder=\"Fist Name\" name=\"ufirstname\"></td>"; echo "<td><input type=\"text\" placeholder=\"Last Name\" name=\"ulastname\"></td>"; echo "<td><input type=\"text\" placeholder=\"Company\" name=\"ucompany\"></td>"; echo "<td><input type=\"text\" placeholder=\"Job Title\" name=\"ujobtitle\"></td>"; echo "<td><input type=\"text\" placeholder=\"Business Phone\" name=\"ubusinessphone\"></td>"; echo "<td><input type=\"text\" placeholder=\"Home Fax\" name=\"uhomefax\"></td>"; echo "<td><input type=\"text\" placeholder=\"Home Phone\" name=\"uhomephone\"></td>"; echo "<td><input type=\"text\" placeholder=\"Mobile Phone\" name=\"umobilephone\"></td>"; echo "<td><input type=\"text\" placeholder=\"E-mail Address\" name=\"uemail\"></td>"; echo "<td>" . "<input type=\"submit\" name=\"add\" value=\"add\"></td>"; echo "</form>"; echo "</table>"; mysql_close($con); ?> <p>Copyright © <?php echo date("Y"); ?> Kuro. All rights reserved.</p>
  13. Hello, I know this should be pretty simple to figure out, but everything I try is giving me absolutely no results. I have a mysql query selecting columns from my database and returning results. I have the results printing out right now, so I can see that this part is working. All I want to do is take the results and put them into a table to display on my page. Basically, take what's in the database table and copy it to a table I can put on the web. FYI I am using sourcerer so the "connect" code is taken care of for me in the "JFactory" bit of code. Here is the first part of my code, selecting the information from the database. {source} <?php $db = JFactory::getDbo(); $query = $db -> getQuery(true); $query -> SELECT($db -> quoteName(array('first_dept_name', 'last_name', 'dept', 'position', 'phone_num'))); $query -> FROM ($db -> quoteName('#__custom_contacts')); $query -> ORDER ('first_dept_name DESC'); $query -> WHERE ($db -> quoteName('contact_category')."=".$db -> quote('YTown Employees')); $db -> setQuery($query); $results = $db -> loadObjectList(); print_r($results); Here is where I am trying to print the results into a table. I got this code directly from a PHP book, but I am getting nothing at all returned back to me. I get table headers, but no data. <?php echo "<table><tr><th>Name</th><th>Department</th></tr>"; while ($row = mysqli_fetch_array ($result)){ echo "<tr>"; echo "<td>".$row['last_name']."</td>"; echo "<td>".$row['dept']."</td>"; echo "</tr>"; } echo "</table>"; ?> {/source}
  14. Hi, My login form is running correctly.i want to add remind me function.please help me. <form class="form-signin" role="form" id="form1" method="post" action="log.php"> <h2 class="form-signin-heading text-center bluetxt">Sign In</h2> <input type="text" id="email1" class="form-control" name="email1" placeholder="Email address" autofocus /><br /> <input type="text" id="pwd1" class="form-control" name="pwd1" placeholder="Password" value=""/><br/> <label class="checkbox"> <input type="checkbox" value="remember" name="remember"> Remember me </label> <input type="submit" value="Login" onclick="ValidationLog()" style="color:#FFF;" class="btn btn-lg btn-primary btn-block"/> </form> <?php $mail = $_POST['email1']; $pwd = $_POST['pwd1']; $con = mysql_connect("localhost","root",""); if(!$con) { die('Could not connect:'.mysql_error()); } mysql_select_db("biz",$con); if((($mail)&&($pwd))==""){ header( 'Location:index.php' ); }else{ $result = mysql_query("SELECT mail,pw FROM reg WHERE mail = '$mail' AND pw = '$pwd'"); $num_rows = mysql_num_rows($result); mysql_close($con); if($num_rows == 0) { } else{ header( 'Location:user/' ); } } ?>
  15. Hi, i'm trying to doing update all table values(name,tel no,country,state,city) without email. using already logged user email(where clase).please help me. php <?php $con=mysqli_connect("localhost","root","","biz"); if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $rd=$_POST['optionsRadiosInline']; $Yname=$_POST['name']; $tp=$_POST['telephone']; $scntry=$_POST['country']; $st=$_POST['state']; $cty=$_POST['city']; if($Yname==""){ header('Location :profile.php'); }else{ echo $st; echo $cty; $result=mysql_query($con,"SELECT mail FROM reg "); $num_rows = mysql_num_rows($result); $row = mysql_fetch_assoc($result); $mail = $row['mail']; if($result){ mysqli_query($con,"UPDATE reg SET radio='$rd',yname='$Yname',tp='$tp',cntry='$scntry',state='$st',city='$cty' WHERE mail='$mail'"); header( 'Location:index.php' ); }else{ echo "first query error"; } } mysqli_close($con); ?> html <form id="form2" method="post" action="up_user.php"> <div class="form-group"> <label class="radio-inline"> <input type="radio" name="optionsRadiosInline" id="optionsRadiosInline1" value="Private" checked=""> Private </label> <label class="radio-inline"> <input type="radio" name="optionsRadiosInline" id="optionsRadiosInline2" value="Business"> Business </label> </div> <label class="">Name</label> <input type="text" class="form-control" placeholder="Your Name" required autofocus name="name" id="name"><br/> <!-- <label class="">Email</label> <input type="email" class="form-control" placeholder="Email address" required name="email" id="email" ><br/>--> <label class="">Telephone Number</label> <input type="text" class="form-control" pattern="\d+" placeholder="Telephone" name="telephone" required name="telephone" id="telephone"><br/> <label>Select Country</label> <select id="country" name="country" onChange="load_options(this.value,'state');"> <option value="">Select country</option> </select> &nbsp <label>Select State</label> <select id="state" name="state" onChange="load_options(this.value,'city');"> <option value="">Select state</option> </select> <label>Select city</label> <select id="city" name="city"> <option value="">Select City</option> </select> <img src="loader.gif" id="loading" align="absmiddle" style="display:none;"/> <br/> <div class="row"> <div class="col-md-4 col-md-offset-4"> <button class="btn btn-lg btn-primary btn-block" type="submit">Update Information</button> </div> </div> </form>
  16. Hello I am trying to work out how many regular users I have to my site and how long those users tend to be users.. So, I have a table that logs every time a user visits my site and logs in, it stores the date / time as a unix timestamp and it logs their user id. I started by getting the id's of any user who logs in more than 5 times in a specified period, but now I want to extend that... SELECT userID as user, count(userID) as logins FROM login_history where timestamp > UNIX_TIMESTAMP('2014-06-01 00:00:00') and timestamp < UNIX_TIMESTAMP('2014-07-01 00:00:00') group by user having logins > 5; So ideally a number of users in each month that visited over x times, users who visited at least x times for 3 months, 6 months, 9 months, 12 months.. Any suggestions would be appreciated Thanks
  17. I have a table with lots of records. My table has the following field, with records containing either NULL or '1' that I need to modify. -- Current `archived` int(1) unsigned DEFAULT NULL But I need to modify it so that it is NOT NULL and defaults to '0'. I have tried the following but it throws an error. -- Error "#1265 - Data truncated for column 'archived' at row 1" ALTER TABLE `proposal_info` MODIFY `archived` INT( 1 ) UNSIGNED NOT NULL DEFAULT '0' -- SAME AS ABOVE EXCEPT NO QUOTES AROUND 0 - Error "#1265 - Data truncated for column 'archived' at row 1" ALTER TABLE `proposal_info` MODIFY `archived` INT( 1 ) UNSIGNED NOT NULL DEFAULT 0 I need to modify the table so that the records that are NULL for that field, will be updated to '0'. I need the records that are currently '1', to retain that value.
  18. Am currently trying to develop a SaaS, where each user gets their own subdomain with their application. Am wondering, though, with installation and subsequent updates: What is the best way to initiate an installation? The project is currently in a git repository. Is it better to simply pull the master branch per installation; or is zipping up the master branch, copying it to the new subdomain, then running the installation a better (secure?) method? What is the best way to initiate an update of code? If using the git repo, hat would deal with updated code, but not updated MySQL tables. Should the user be allowed to choose to update (so much like W$, a popup shows up that says there's an update; user can choose to update or ignore); or should all updates be forced (such as at a certain time)? I haven't seen much online with my searches, but I may be blind at this point. Any thoughts/comments appreciated!
  19. I have a server script with which i have allowed the user to mark any item as favorite, but i also want another script through which the user can unfavorite the same item if they want and that item should be deleted from their favorite list. I have kept the same table for both favorite and unfavorite code, therefore i have used update query to update the details. For this purpose i have a code, but its not working, as i am new in the programming field would appreciate if someone could provide the correct codes <?php require_once('config.php'); $favorite = $_REQUEST['favorite']; $unfavorite = $_REQUEST['unfavorite']; $id=$_REQUEST['id']; $unfavoritedeal=mysql_query("SELECT * FROM favoritedeals where id='".$id."'"); //favoritedeals is the name of the table if($row=mysql_fetch_array($unfavoritedeal)) { $favorite=$row['favorite']; $unfavorite=$row['unfavorite']; } $myfavorite=(isset($_REQUEST['favorite'])?$_REQUEST['favorite']:$favorite); $myunfavorite=(isset($_REQUEST['unfavorite'])?$_REQUEST['unfavorite']:$unfavorite); $update = mysql_query("update favoritedeals set favorite = '".$myfavorite."', unfavorite = 1 where id = '".$id."'"); if(unfavorite="1" where id='".$id."') { "delete from favoritedeals WHERE id= '".$id."'"; } $posts[0]['message'] = 'favorite list updated'; $selectt = mysql_query("select * from favoritedeals where id = '".$id."'"); $results = mysql_fetch_assoc($selectt); $posts[0]['detail'] = $results; header('Content-type: application/json'); echo json_encode($posts); ?>
  20. Hello There I've created an Voucher In MySQL/Database system. I would like to know how would I go about programming it into my shopping cart so when a client has an secret Voucher / Coupon they can have a percentage off of the total price of the items their trying to purchase then place thats final price into paypal checkout. shopping cart and database of the Voucher shown below thanks in advance. <?php require "connect_query.php"; $voucher = "CREATE TABLE `voucher_code` ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT , `vouchercode` VARCHAR( 16 ) NOT NULL , `active` TINYINT( 1 ) NOT NULL , `min_basket_cost` FLOAT NOT NULL , `voucher_operation` ENUM( '-', '%', 's' ) NOT NULL , `voucher_amount` FLOAT NOT NULL , `num_vouchers` INT( 11 ) NOT NULL DEFAULT '-1', `expiry` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , PRIMARY KEY ( `ID` )"; if (mysqli_query($db_conx,$voucher)){ echo "Vouchar Table has been CREATED :)"; }else{ echo "Vouchar TABLE was not a success :("; } ?> ////////////////////////////////////// Cart.php <?php // Start session first thing in script session_start(); // Script Error Reporting error_reporting(E_ALL); ini_set('display_errors', '1'); // Connect to the MySQL database include "connect_prompt/connect_query.php"; ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 1 (if user attempts to add something to the cart from the product page) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['pid'])) { $pid = $_POST['pid']; $size = $_POST['size']; $wasFound = false; $i = 0; // If the cart session variable is not set or cart array is empty if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { // RUN IF THE CART IS EMPTY OR NOT SET $_SESSION["cart_array"] = array(1 => array("item_id" => $pid, "size" => $size, "quantity" => 1)); } else { // RUN IF THE CART HAS AT LEAST ONE ITEM IN IT foreach ($_SESSION["cart_array"] as $each_item) { $i++; while (list($key, $value) = each($each_item)) { if ($key == "item_id" && $value == $pid){ if ($each_item['size'] == $size){ // That item is in cart already so let's adjust its quantity using array_splice() array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $pid, "size" => $size, "quantity" => $each_item['quantity'] + 1))); $wasFound = true; }} // close if condition } // close while loop } // close foreach loop if ($wasFound == false) { array_push($_SESSION["cart_array"], array("item_id" => $pid,"size" => $size, "quantity" => 1)); } } header("location: cart.php"); exit(); } ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 2 (if user chooses to empty their shopping cart) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_GET['cmd']) && $_GET['cmd'] == "emptycart") { unset($_SESSION["cart_array"]); } ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 3 (if user chooses to adjust item quantity) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['item_to_adjust']) && $_POST['item_to_adjust'] != "") { // execute some code $item_to_adjust = $_POST['item_to_adjust']; $size = $_POST['size']; $quantity = $_POST['quantity']; $quantity = preg_replace('#[^0-9]#i', '', $quantity); // filter everything but numbers if ($quantity >= 100) { $quantity = 99; } if ($quantity < 1) { $quantity = 1; } if ($quantity == "") { $quantity = 1; } $i = 0; foreach ($_SESSION["cart_array"] as $each_item) { $i++; while (list($key, $value) = each($each_item)) { if ($key == "item_id" && $value == $item_to_adjust) { if ($each_item['size'] == $size ){ // That item is in cart already so let's adjust its quantity using array_splice() array_splice($_SESSION["cart_array"], $i-1, 1, array(array("item_id" => $item_to_adjust, "quantity" => $quantity, "size" => $size))); } // close if condition } // close while loop } // close foreach loop } } ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 4 (if user wants to remove an item from cart) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (isset($_POST['index_to_remove']) && $_POST['index_to_remove'] != "") { // Access the array and run code to remove that array index $key_to_remove = $_POST['index_to_remove']; if (count($_SESSION["cart_array"]) <= 1) { unset($_SESSION["cart_array"]); } else { unset($_SESSION["cart_array"]["$key_to_remove"]); sort($_SESSION["cart_array"]); } } ?> <?php ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Section 5 (render the cart for the user to view on the page) ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// $cartOutput = ""; $cartTotal = ""; $pp_checkout_btn = ''; $product_id_array = ''; if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) { $cartOutput = "<h2 align='center'>Your shopping cart is empty</h2>"; } else { // Start PayPal Checkout Button $pp_checkout_btn .= '<form action="[url=https://www.paypal.com/cgi-bin/webscr]https://www.paypal.com/cgi-bin/webscr[/url]" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="myemail@gmail.com">'; // Start the For Each loop $i = 0; foreach ($_SESSION["cart_array"] as $each_item) { $item_id = $each_item['item_id']; $sql = "SELECT * FROM products WHERE id='$item_id' LIMIT 1"; $query = mysqli_query ($db_conx,$sql); while ($row = mysqli_fetch_array($query)){ $product_name = $row["product_name"]; $price = $row["price"]; $details = $row["details"]; $taxes = $row["taxes"]; $shipping_one =$row['shipping_one']; } $pricetotal = $price * $each_item['quantity']; $cartTotal = $pricetotal + $shipping_one + $taxes + $cartTotal; setlocale(LC_MONETARY, "en_US"); //$pricetotal = money_format("%10.2n", $pricetotal); // Dynamic Checkout Btn Assembly $x = $i + 1; $pp_checkout_btn .= ' <input type="hidden" name="item_name_' . $x . '" value="' . $product_name . '"> <input type="hidden" name="amount_' . $x . '" value="' . $price . '"> <input type="hidden" name="quantity_' . $x . '" value="' . $each_item['quantity'] . '"> <input type="hidden" name="handling_'. $x . '"value="'. $shipping_one .'"> <input type="hidden" name="tax_'. $x . '"value="'. $taxes .'"> <input type="hidden" name="on0_' . $x . '" value="' . $each_item['size'] . '">'; // Create the product array variable $product_id_array .= "$item_id-".$each_item['quantity'].","; // Dynamic table row assembly $cartOutput .= "<tr>"; $cartOutput .='<td><a href="product.php?id=' . $item_id . '">' . $product_name . '</a><br /><img src="inventory_images/' . $item_id . '.jpg" alt="' . $product_name. '" width="40" height="52" border="1" /></td>'; $cartOutput .= '<td>' . $each_item['size'] .'</td>'; $cartOutput .= '<td>' . $details . '</td>'; $cartOutput .= '<td>$' . $price . '</td>'; $cartOutput .= '<td><form action="cart.php" method="post"> <input name="quantity" type="text" value="' . $each_item['quantity'] . '" size="1" maxlength="2" /> <input name="adjustBtn' . $item_id . '" type="submit" value="change" /> <input name="item_to_adjust" type="hidden" value="' . $item_id . '" /> </form></td>'; //$cartOutput .= '<td>' . $each_item['quantity'] . '</td>'; $cartOutput .= '<td>' . $pricetotal . '</td>'; $cartOutput .= '<td><form action="cart.php" method="post"><input name="deleteBtn' . $item_id . '" type="submit" value="X" /><input name="index_to_remove" type="hidden" value="' . $i . '" /></form></td>'; $cartOutput .= '</tr>'; $i++; } setlocale(LC_MONETARY, "en_US"); // $cartTotal = money_format("%10.2n", $cartTotal); $cartTotal = "<div style='font-size:18px; margin-top:12px;' align='right'>Cart Total : ".$cartTotal." USD</div>"; // Finish the Paypal Checkout Btn $pp_checkout_btn .= '<input type="hidden" name="custom" value="' . $product_id_array . '"> <input type="hidden" name="notify_url" value="[url=https://www.shopstorms.com/storescripts/my_ipn.php]https://www.shopstorms.com/storescripts/my_ipn.php">[/url] <input type="hidden" name="return" value="[url=https://www.mywebsite.com/checkout_complete.php]https://www.mywebsite.com/checkout_complete.php">[/url] <input type="hidden" name="rm" value="2"> <input type="hidden" name="cbt" value="Return to The Store"> <input type="hidden" name="cancel_return" value="[url=https://www.mywebsite.com/paypal_cancel.php]https://www.mywebsite.com/paypal_cancel.php">[/url] <input type="hidden" name="lc" value="US"> <input type="hidden" name="currency_code" value="USD"> <input type="image" src="[url=http://www.paypal.com/en_US/i/btn/x-click-but01.gif]http://www.paypal.com/en_US/i/btn/x-click-but01.gif[/url]" name="submit" alt="Make payments with PayPal - its fast, free and secure!"> </form>'; } ?> <?php if(!empty($pricetotal)) { ?> <?php $discount =""; if($pricetotal >= 50){ echo "FREE SHIPPING!"; } elseif ($pricetotal <= 50){ echo "SPEND MORE THAN 50 GET FREE SHIPPING!"; } ?> <?php } ?> <body> <div align="center" id="mainWrapper"> <div id="pageContent"> <div style="margin:24px; text-align:left;"> <br /> <table width="1024" border="1" cellspacing="0" cellpadding="6" align="center" style="background-color:white;"> <tr> <td width="18%" bgcolor="#C5DFFA"><strong>Product</strong></td> <td align="center" width="10%" bgcolor="#C5DFFA"><strong>Size</strong></td> <td width="45%" bgcolor="#C5DFFA"><strong>Product Description</strong></td> <td width="10%" bgcolor="#C5DFFA"><strong>Unit Price</strong></td> <td width="9%" bgcolor="#C5DFFA"><strong>Quantity</strong></td> <td width="9%" bgcolor="#C5DFFA"><strong>Total</strong></td> <td width="9%" bgcolor="#C5DFFA"><strong>Remove</strong></td> </tr> <?php echo $cartOutput; ?> <!-- <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> --> </table> <table width="1024" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <th scope="col" align="left"><a href ="cart.php?cmd=emptycart">Click Here to Empty Your Shopping Cart</a></th> <th scope="col" align="center" style="color:black;"> <?php if(!empty ($taxes)) { ?> <?php echo $taxes; ?> <?php } ?> <br/> <?php if(!empty ($shipping_one)) { ?> <?php echo $shipping_one; ?> <?php } ?> <br/> <?php if(!empty ($cartTotal)) { ?> <?php echo $cartTotal; ?> <?php } ?> <br/><?php if(!empty ($discount)) { ?> <?php echo $discount; ?> <?php } ?> <br/> </th> </tr> </table> <table width="1024" height="50" border="0" cellspacing="10" cellpadding="0" align="center"> <tr> <th width="913" align="left" scope="col"></th> <th width="105" align="right" scope="col"><?php echo $pp_checkout_btn; ?> </th> </tr> </table> <br /> <br /> <br /> <br /> </div> <br /> </div> </div> </body> </html>
  21. Hi All I am having problems running a query to get the courses a student is enrolled for. The format I need is somthing like this: firstname - lastname - course ------------------------------------------- Joe Bloke US232456 Joe Bloke US554665 Joe Bloke US332098 or like this firstname - lastname - course ------------------------------------------------- Joe Bloke US232456 US554665 US332098 The query I am running is SELECT usr.firstname, usr.lastname, c.shortname FROM mdl_course c INNER JOIN mdl_context cx ON c.id = cx.instanceid AND cx.contextlevel = '50' INNER JOIN mdl_role_assignments ra ON cx.id = ra.contextid INNER JOIN mdl_role r ON ra.roleid = r.id INNER JOIN mdl_user usr ON ra.userid = usr.id WHERE r.name = 'Learner' AND usr.firstname = 'G01 Moloko' ORDER BY usr.firstname, c.shortname The problem is that I know this student is enrolled for 3 courses, but it only returns 1 course. Any help is welcomed. huck
  22. hello every1 I am creating a login script using pdo.. The problem i;m facing is that inspite of giving the right login details, it shows "wrong username / password." The pdo code is shown below function login_members($uname,$pwd,$type) { $q = $this->connect()->prepare("SELECT * FROM members WHERE username='?' AND password='?' AND type='?' LIMIT 1"); $q->bindParam(1, $username,PDO::PARAM_STR); $q->bindParam(2, $pwd,PDO::PARAM_STR); $q->bindParam(3, $type,PDO::PARAM_STR); if($q->execute()) { $row = $q->fetch(PDO::FETCH_ASSOC); if(($row['username']===$uname) && ($row['password']===$pwd)) { return TRUE; } else { return FALSE; } } else { return FALSE; } } in the main page if($pdo->login_members($uname,$pwd,$type)) { echo "<div class='correct_message' style='display:block'>You have been successfully logged in...</div>"; } else { echo "<div class='error_message' style='display:block'>wrong username / password</div>"; } Any help will be greatly appreciated....
  23. Hi, I'm not sure if this is the right forum to post this question, but I'll still post it. I'm a newbie programmer, have 1 year experience of php, mysql and html and know how to make a basic website, but I've never actually uploaded the already written code on the internet.So my question is, if you use vertrigo serv and have folders full of php files, what do you do after getting a domain? I read that dreamweaver does that for you, but i also read that it is a closed source software with limitations if you get the free version.The other choice is using FileZilla(which I don't fully understand yet ) i presume.
  24. I am trying to add a simple pagination to my page. I know there are tons of tutorials out there for this. Well I have taken one of them and used my own queries with it. Below is the code. The records do show up. The only problem is that all the records(from mysql table) show up, as oppose to limiting them per page. Can you take a look at it and tell me what I might be doing wrong? try { // Find out how many items are in the table $total = DB::getInstance()->query("SELECT COUNT(*) FROM records"); // How many items to list per page $limit = 20; // How many pages will there be $pages = ceil($total / $limit); // What page are we currently on? $page = min($pages, filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array( 'options' => array( 'default' => 1, 'min_range' => 1, ), ))); // Calculate the offset for the query $offset = ($page - 1) * $limit; // Some information to display to the user $start = $offset + 1; $end = min(($offset + $limit), $total); // Prepare the paged query $stmt = DB::getInstance()->query("SELECT images.*, records.* FROM records LEFT JOIN images ON records.user_id = images.user_id ORDER BY record_id LIMIT {$limit} OFFSET {$offset}"); if($stmt->count()) { // Display the results foreach($stmt->results() as $row) { $thumb_img = escape($row->thumb_path); $title = trim($row->title); ?> <div class="item"> <?php echo $thumb_img; ?> <?php echo $title; ?> </div> <?php } } else { echo '<p>No results could be displayed.</p>'; } // The "back" link $prevlink = ($page > 1) ? '<a href="?page=1" title="First page">«</a> <a href="?page=' . ($page - 1) . '" title="Previous page">‹</a>' : '<span class="disabled">«</span> <span class="disabled">‹</span>'; // The "forward" link $nextlink = ($page < $pages) ? '<a href="?page=' . ($page + 1) . '" title="Next page">›</a> <a href="?page=' . $pages . '" title="Last page">»</a>' : '<span class="disabled">›</span> <span class="disabled">»</span>'; // Display the paging information echo '<div id="paging"><p>', $prevlink, ' Page ', $page, ' of ', $pages, ' pages, displaying ', $start, '-', $end, ' of ', $total, ' results ', $nextlink, ' </p></div>'; } catch (Exception $e) { echo '<p>', $e->getMessage(), '</p>'; } ?>
  25. hello every one I have some queries in mysql command.. I have a table schema like this id | name | url | img1 | img2 | img3 | img4| I want to randomly rotate the image by specific id.... suppose the select the id = 1, then the four images will be rotated randomly for with the tha id (i.e id = 1) Any help wil greatly appreciated Thank u.....
×
×
  • 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.