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. I am trying to set a column equal to the column in another table where the date matches. I seem to have a problem in my query and I have tried multiple methods. Can someone tell me where the mistake is? $query2 = "UPDATE a SET a.CalDatePrice = b.Close FROM ". $symbol ." b INNER JOIN CleanedCalendar a ON a.BuyDate = b.Date"; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM CLBS b INNER JOIN CleanedCalendar a ON a.BuyDate = b.Dat' at line 3
  2. hello mate, i need help on creating the json file with data are fetched from mysql database. here will be the result i want to get. { "freebusys":[ { "start":"2012-12-20T16:29:34.000+0000", "end":"2013-02-06T16:44:24.000+0000", "free":true } ], "events":[ { "start":"2013-01-04T03:57:06.000+0000", "end":"2013-02-18T03:57:06.000+0000", "id":2, "title":"A lesson" }, { "start":"2013-01-04T12:43:30.000+0000", "end":"2013-02-18T12:43:30.000+0000", "id":4, "title":"A lesson" } ] } i have a table named "schedules" on my database with the following fields, start, end, id, title, and free, all i need is to do php array "freebusys" and "events" then their values will be fetched from my database. how can i do this. please help. Thank you
  3. Hello all, I have a simple PHP page that queries a database and outputs the result set in an HTML table. It works fine. However, the result set is relatively large (2500ish records), so I want to apply a filter. Added an HTML form to the page that lets us filter the criteria. Again, works great. (Used GET method so that the URL could be linked). Here's where my problem comes about. My boss wants the filters to be persistent, both within and between sessions. My first thought was cookies.. so I created a function called Filter() and call it at the top of my PHP document. It reads the cookie and applies the filters into the SQL statement. This works, but is rather kludgy. The problem I have is that when I first access the page, it doesn't seem to see the filters, it displays the full 2500ish record set. However, if I do a CTRL-R to reload the page, it then loads the filters correctly... it's almost like it renders the page before it can read the cookies in the initial pass. Any thoughts on how to improve this, or am I taking a totally wrong approach?
  4. I'm currently using a external module from an opencart vendor on my opencart store, however I keep getting a error stating mysql has gone away. Thinking this might be an issue with the mysql wait time setting I contacted my server support team and asked them to investigate, below is there answer. I'm struggling to understand exactly why the query is so badly designed as stated below, any advice on the subject would be greatly appreciated
  5. I am having a mysql table named `company_profile`. It may have only one record. So I tried to insert and update data of the table using `INSERT.... ON DUPLICATE KEY UPDATE` query. My query is something like this: $sql = "INSERT INTO company_profile ( company_name , tel , mobile , fax , email ) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE company_name= VALUES(company_name) , tel = VALUES(tel) , mobile = VALUES(mobile) , fax = VALUES(fax) , email = VALUES(email)"; $stmt = $mysqli->prepare($sql); $stmt->bind_param('sssss', $company_name , $telephone , $mobile , $fax , $email ); $stmt->execute(); My problem is when I updating the data, it always inserting a new record into my table. Can anybody tell me what would be the problem of this? My table structure looks like this: CREATE TABLE IF NOT EXISTS company_profile ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, company_name VARCHAR(120) NOT NULL, tel VARCHAR(20) NOT NULL, mobile VARCHAR(20) NOT NULL, fax VARCHAR(20) DEFAULT NULL, email VARCHAR(60) NOT NULL, PRIMARY KEY (id), UNIQUE KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  6. I'm getting the following errors when I run `cat /var/log/apache/error.log` -> PHP Notice: Undefined variable: db_connection in /var/www/html/popreport/includes/inmate.php on line 18 -> PHP Fatal error: Call to a member function query() on a non-object in /var/www/html/popreport/includes/inmate.php on line 18 When I try this in my browser I start with test.php test.php <?php require_once("./database.php"); require_once("./inmate.php"); // foreach($query as $row) // { // print_r($row) . "<br />"; // } $inmate = array(); $inmate = new Inmate($inmate); foreach($inmate as $row) { print $row->firstl_name . "<br />"; } ?> database.php <?php include("./constants.php"); try { $db_connection = new PDO("mysql:host=$host;dbname=$db_name", $db_user, $password); $db_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br />"; die(); } ?> inmate.php <?php require_once("./database.php"); class Inmate { private $first_name = ''; private $last_name = ''; private $full_name = ''; private $race = ''; private $number = 0; private $facility = ''; private $type_of_transit = ''; public function __construct($inmate) { $sql = "SELECT * FROM inmate_board"; $query = $db_connection->query($sql); $result = $query->fetch(PDO::FETCH_ASSOC); foreach($result as $row) { $this->$first_name = $result['first_name']; } } public function get_property($property) { return $this->$property; } } ?> In inmate.php I also tried to change the line `$query = $db_connection->query($sql);` to `$query = global $db_connection->query($sql);` but I didn't have any luck here either. Any ideas?
  7. Hi Peeps So basically im creating a "customer page" i have 2 tabs, 1 is customer info which is the primary and the invoicing tab I have a date picker in the invoicing tab which im hoping will populate a table below. I tried having the form post to php but this resets the page which then goes to the customer info tab so im guessing this will have to be done with jquery and ajax. could someone please point me in the right direction to do this? here is the current page for better explanation: All help is greatly appreciated in advance Mooseh
  8. $sql = "UPDATE `Room_users` SET `kick` = :kick WHERE kick < UNIX_TIMESTAMP()"; So this is my update query, normally I store the time in the kick field in unix format but there is cases where I store the value "Permanently" in that field as well is there a way to change the query to do nothing if the field value is "Permanently" but if the value is unix time then it should update the query?
  9. Hi I got 3 tables Table 1 id room pin creator mxitid time Table 2 id roomid user message time mxitid Table 3 id user mxitid room roomid rank kick unid Each room I create I place the new epoch time of when the room expire in Table 1 time field. But now im trying to create a script to check if my current time is bigger than the time in the Table 1 time field and if it is so it should delete the row in table 1, the rows in table 2 with the same roomid as the id of table 1 and the rows in table 3 with the same roomid as the id of table 1 How can I loop through all the records to delete the expired rooms info using PDO mysql?
  10. I have three tables in my database listed below: Table: teams_info team_id team_name entry_year status 1 team 1 2015 1 2 team 2 2015 1 3 team 2 2016 1 Table: team_players player_id team_id status members_id position 1 1 0 1 1 2 1 1 2 2 3 1 1 3 3 4 1 1 4 4 5 2 0 5 1 6 2 0 6 2 7 2 1 7 3 Table: members members_id first_name surname gender 1 joe blogg male 2 james smith male 3 sarah marshall female 4 tony walker male 5 peter jones male 6 jessica varley female 7 jane varley female I'm trying to get my head around how I would get the following information, 1) How many team_players from team_info.entry_year = 2015 have accepted the to join a team (this will be all players with status = 1) 2) How many team_players from team_info.entry_year = 2015 have been invited (basically counting all records that belong to 2015 teams) 3) The total Males players from 2015 teams. 4) The total female players from 2015 teams. i'm fairly new to SQL and it seems I have made things complicated whilst trying to follow the best standards, however I can not wrap my head around where to start. Any help would be greatly appreciated.
  11. Hi, I'm recalling information from my database to show all the birthdays of the specific day but today the 30th of November 2015 I get a list of everyone who is stored in my database showing as if its their birthday. Somewhere I made a mistake my database field is DateTime $querybd = "SELECT Username, pdob FROM Users2"; $resultbd = mysql_query($querybd) or die(mysql_error()); $users = array(); while($rowbd = mysql_fetch_array($resultbd)){ if (date('m-d', strtotime($rowbd['pdob'])) == date('m-d')) $users[] = $rowbd['Username']; } $list = implode('; ', $users); if($list == ""){}else{ echo "<br><b>Todays Birthdays: </b>" . $list . "<br>"; } It worked fine till today
  12. I am trying out a new script that lets me resize an image before uploading. It is based on this script. http://www.w3bees.com/2013/03/resize-image-while-upload-using-php.html Basically what happens is, it resizes and makes 3 thumbnails and puts them in their relative folder. That works. The part that's giving me the problem is when inserting it into the database. Error says the "image_path" cannot be null. Since it's creating an array of 3 different thumbnails, should I create 2 more fields in the database tabel to account for that? If so, how would I insert the 3 different thumbnail paths into the query? What would it look like? Below is my code. <?php $db_userid = intval($row['user_id']); $get_item_id = intval($row['item_id']); // settings $max_file_size = 5242880; // 5mb $valid_exts = array('jpeg', 'jpg', 'png', 'gif'); // thumbnail sizes $sizes = array(100 => 100, 150 => 150, 250 => 250); // dir paths $target_dir = 'images/'.$db_userid.'/items/'.$get_item_id.'/'; if ($_SERVER['REQUEST_METHOD'] == 'POST' AND isset($_FILES['image'])) { if(!empty($_FILES['image']['name'])) { if($_FILES['image']['size'] < $max_file_size ){ // get file extension $ext = strtolower(pathinfo($_FILES['image']['name'], PATHINFO_EXTENSION)); if(in_array($ext, $valid_exts)) { function resize($width, $height){ global $db_userid; global $get_item_id; /* Get original image x y*/ list($w, $h) = getimagesize($_FILES['image']['tmp_name']); /* calculate new image size with ratio */ $ratio = max($width/$w, $height/$h); $h = ceil($height / $ratio); $x = ($w - $width / $ratio) / 2; $w = ceil($width / $ratio); /* new file name */ $path = 'images/'.$db_userid.'/items/'.$get_item_id.'/'.$width.'x'.$height.'_'.$_FILES['image']['name']; /* read binary data from image file */ $imgString = file_get_contents($_FILES['image']['tmp_name']); /* create image from string */ $image = imagecreatefromstring($imgString); $tmp = imagecreatetruecolor($width, $height); imagecopyresampled($tmp, $image, 0, 0, $x, 0, $width, $height, $w, $h); /* Save image */ switch ($_FILES['image']['type']) { case 'image/jpeg': imagejpeg($tmp, $path, 100); break; case 'image/png': imagepng($tmp, $path, 0); break; case 'image/gif': imagegif($tmp, $path); break; default: exit; break; } return $path; /* cleanup memory */ imagedestroy($image); imagedestroy($tmp); } /* resize image */ foreach($sizes as $w => $h) { if(!is_dir($target_dir)){ mkdir($target_dir, 0775, true); } $files[] = resize($w, $h); } $insert_image = $db->prepare("INSERT INTO images(user_id, item_id, image_path, date_added) VALUES(:user_id, :item_id, :image_path, :date_added)"); $insert_image->bindParam(':user_id', $db_userid); $insert_image->bindParam(':item_id', $get_item_id); $insert_image->bindParam(':image_path', $path); $insert_image->bindParam(':date_added', $item_date_added); if(!$insert_image->execute()) { $errors[] = 'There was a problem uploading the image!'; } else { if(empty($errors)) { $db->commit(); $success = 'Your item has been saved.'; } else { $db->rollBack(); } } } else { $errors[] = 'Unsupported file'; } } else{ $errors[] = 'Please upload image smaller than 5mb'; } } else { $errors[] = 'An image is required!'; } }
  13. I do have 3 mysql tables "users", "banks", and "user_bank". Every users must have at least one bank and maximum is two. When users signup to system I need to insert bank details to `user_bank` table also. This is how I tried it: $success=FALSE; if($success == FALSE) { $query = "INSERT INTO user_bank ( beneficiary_id , beneficiary_bank_id , branch_id ) VALUES (?, ?, ?)"; $stmt = $mysqli->prepare($query); $stmt->bind_param('iii', $lastInsertId , $bank_one , $branchId_one ); $stmt->execute(); if ($stmt->affected_rows == 1) { $success=TRUE; if(!empty($bank_two) && !empty($branchId_two)) { $query = "INSERT INTO user_bank ( id , bank_id , branch_id ) VALUES (?, ?, ?)"; $stmt = $mysqli->prepare($query); $stmt->bind_param('iii', $lastInsertId , $bank_two , $branchId_two ); $stmt->execute(); $success=TRUE; } } } if ($success == TRUE) { $messages = array('success'=>true, 'message'=>'You successfully registered.'); } My question is, can anybody tell me I there a way to use a single query for this? If so how its doing? Thank you.
  14. Hi guys, I am trying to make a quick code to find a route between two Place A and Place Z on 2015-11-23 that starts to leave after 6am. Example table rows: DATE DEPARTURE LEAVE ARRIVE ARRIVAL 2015-11-23 Place A 04:00 Place Z 06:00 (this direct route leaves too early.) 2015-11-23 Place U 13:30 Place Z 14:20 2015-11-23 Place A 07:00 Place T 08:00 2015-11-23 Place A 09:00 Place U 12:00 2015-11-23 Place T 09:00 Place B 12:00 2015-11-23 Place B 13:00 Place Z 15:00 The output will show all routes available such as: OPTION 1: Place A to Place U (09:00-12:00) **01:30 wait** Place U to Place Z (13:30-14:20) OPTION 2: Place A to Place T (07:00-08:00) **01:00 wait** Place T to Place B (09:00-12:00) **00:45 wait** Place B to Place Z (12:45-15:00) Thanks for the help
  15. Hi, Apologies if this isn't the right forum for this question. I couldn't find the perfect forum for my question, but I'm hoping someone can help. Basically, I've been having problems with a site I manage, with the site going down regularly, 401 Forbidden error pages cropping up reguarly, as well as Server Configuration Error pages, although only ever sporadically. I've been trying everything to work out the issue but no luck as of yet. However, one thing that seems strange is the following messages that I'm getting in the access logs. Now, this shouldn't be a problem as Facebook often creates messages like these when it's accessing files from a server. However, there are thousands of messages like this that reference files that don't exist. Honestly, it's constantly trying to access .jpg files that don't exist, and so I suspect this is what's causing the server to keep crashing. Has anyone had anything similar to this before? comono.co.uk 173.252.88.88 - - [20/Nov/2015:13:13:46 +0000] "GET /uploads/2009/9/28/873128bf77.jpg HTTP/1.1" 403 379 "-" "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)" Thanks, Russ
  16. Hi guys, I have this code here http://pastebin.com/WK36Jx0G It works as it should for the first loop but for each re-loop though I get the output 'Array' echoing from line 41's output. Example shown below.. From: MAN STR DUB 12:15 - 20:05 From: MANArray DUB SNN 17:30 - 23:15 Anyone understand why? Thanks
  17. Hello, This is my first attempt at sql sub queries, so please excuse me if it's something very silly. Below is my sql: SELECT td.*, CONCAT(me.First_Name,' ', me.Surname) AS managers_full_name, me.Telephone AS managers_telephone, td.status AS status FROM `team_details` td JOIN `members` me ON me.id = td.managers_user_id JOIN (SELECT COUNT(*) AS nap FROM `team_players`) AS tp ON td.team_id = tp.team_id WHERE tp.status = '1' WHERE td.entry_year = '2016' The SQL executed fine before I added the second join with a sub query, now I'm getting the following error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE td.entry_year = '2016' LIMIT 0, 25' at line 5 Is this not the correct way of sub querying, or have I missed something? Any help would be greatly appreciated.
  18. hello guyz am newbie in mysql php..i want if any user register. in my admin area there is reminder of fees .like id 1 simran join date 7-10-2015 after 30 days in my admin area reminds simran's fees is pending..any one plz help me ...thnxx in advance here is table name users
  19. Hello, I'm trying to output my database on my website but it's not working, it shows up just a blank page ( http://prntscr.com/90dfbf ), here's the code : <html> <head> <title>Untitled</title> </head> <body> <?php require_once(‘conn.php’); $sql = ("SELECT * FROM oglasi"); $query = mysql_query($sql); while ($row = mysql_fetch_array($query)) { $naziv = $row[‘naziv’]; $sadrzaj = $row[‘sadrzaj’]; echo $naziv; echo $sadrzaj; }; ?> </body> </html> And conn.php is: <?php $conn = mysql_connect(‘localhost’, ‘root’, ‘ELsk0l@r00t’) or die (mysql_error()); mysql_select_db(‘elskoglasi’) or die (‘Database selection incorrect’); ?>
  20. Why I start this tread is, Just I need to create a secure user registration system in php including login functionality with remember me option. In the starting point I needed to create user registration script. Here I have include my code so far, and just I need to know , is my script secure to prevent any possible attack? my password hashing method is correct? If not can any profession guys tell me what are the things that I need to do to make this script more secure? This is my PHP so far from user registration script: <?php // Error Flag $error_msg = ""; if (isset($_POST['username'], $_POST['email'], $_POST['password'])) { // Sanitize and validate the data passed in $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING); $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL); $email = filter_var($email, FILTER_VALIDATE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $error_msg .= 'The email address you entered is not valid'; } $password = filter_input(INPUT_POST, 'ppassword', FILTER_SANITIZE_STRING); $prep_stmt = "SELECT member_id FROM members WHERE email = ? LIMIT 1"; $stmt = $mysqli->prepare($prep_stmt); if ($stmt) { $stmt->bind_param('s', $email); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows == 1) { // A user with this email address already exists $error_msg .= 'A user with this email address already exists.'; } } else { $error_msg .= 'Database error'; } if (empty($error_msg)) { // Create a random salt //$random_salt = hash('sha512', uniqid(openssl_random_pseudo_bytes(16), TRUE)); // Did not work $random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true)); // Create salted password $password = hash('sha512', $password . $random_salt); // Insert the new user into the database if ($insert_stmt = $mysqli->prepare("INSERT INTO members (username, email, password, salt) VALUES (?, ?, ?, ?)")) { $insert_stmt->bind_param('ssss', $username, $email, $password, $random_salt); // Execute the prepared query. if (!$insert_stmt->execute()) { header('Location: ../error.php?err=Registration failure: INSERT'); exit(); } } // Success massege $success = "The account has been created successfully."; // Store success massege in SESSION: $_SESSION['success'] = $success; // Redirect page to same page $url = BASE_URL.BASE_URI.'index.php?p=admin-dashboard'; // Define the URL. header("Location: $url"); exit(); // Quit the script. } } ?> Any comments would be greatly appreciate. Thank you.
  21. I would like to thank everyone helping me on my previous question. This is the last question i have. Currently i have my program running but i just need to figure out how to use the get function on check boxes and text boxes. Here is the code i am using for the php mysql part of it. <?php $con=mysqli_connect("localhost","username","password","dbase"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $sql="SELECT * from table where id = '".$_GET["id"]."' "; $rs=mysql_query($sql,$conn) or die(mysql_error()); ?> I know this is working by echoing what i needed to display. But i am in a situation where the form is extremely large and i need to display it in the what it is setup currently. Here is an example of the form <form name="standard" method="post" action="submit.php"> <table width="100%" height="1295" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top" background="../test report page/images/test form standard large2.jpg" ><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="35" height="122"> </td> <td width="920"> </td> <td width="45"> </td> </tr> <tr> <td height="49"> </td> <td valign="top"><table width="100%" height="44" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="25%" valign="bottom"> <input name="water-purveyor" type="text" id="water-purveyor" size="25" height="25" value="<?php echo'.$result["water-purveyor"].' ?>" /></td> <td width="20%" valign="bottom"> <input type="text" name="facility-contact" id="facility-contact" height="25" value="<?php echo'.$result["facility-contact"].' ?>" /></td> <td width="55%" valign="bottom"><input type="text" name="facility-address" id="facility-address" size="50" height="25" value="<?php echo'.$result["facility-address"].' ?>" /></td> </tr> </table></td> <td> </td> </tr> <tr> <td width="28%" height="85" valign="bottom"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2" rowspan="2"> </td> <td width="15%" height="33"><input type="checkbox" name="v1-na" id="v1-na" value="<?php echo'.$result["v1-na"].' ?>" /></td> <td width="14%"><input type="checkbox" name="v1-good" id="v1-good" value="<?php echo'.$result["v1-good"].' ?>" /></td> <td width="15%"><input type="checkbox" name="v1-poor" id="v1-poor" value="<?php echo'.$result["v1-poor"].' ?>" /></td> <td width="15%"><input type="checkbox" name="v1-fail" id="v1-fail" value="<?php echo'.$result["v1-fail"].' ?>" /></td> </tr> <tr> <td height="35" valign="top" style="padding-top:4px;"><input type="checkbox" name="v2-na" id="v2-na" value="<?php echo'.$result["v2-na"].' ?>" /></td> <td valign="top" style="padding-top:4px;"><input type="checkbox" name="v2-good" id="v2-good" value="<?php echo'.$result["v2-good"].' ?>" /></td> <td valign="top" style="padding-top:4px;"><input type="checkbox" name="v2-poor" id="v2-poor" value="<?php echo'.$result["v2-poor"].' ?>" /></td> <td valign="top" style="padding-top:4px;"><input type="checkbox" name="v2-fail" id="v2-fail" value="<?php echo'.$result["v2-fail"].' ?>" /></td> </tr> </table> </form> Can you tell me if this will work or can you give me some helpful ways to make this work. Again thank you for all your help. E
  22. Hi, Ive got a few records stored in my database and would wish to remove records older than 30 days. The thing is I got a field in my database table called pprofilepic which contains the directory of an image stored on my host. I would like to delete the image before removing the record from the database. Would I need to use the while loop to do so? Here is an example of database records output in php array $Users2 = array( array('ID' => '1','Username' => 'Cobus','mxitid' => 'Debater','mxitlogin' => '','nick' => '','phone' => '','location' => '','rank' => '1','registered' => '1443554980','last_online' => '1446482291','ip1' => '165.255.107.53','ip2' => '165.255.107.53','pprofilepic' => 'uploads/resized_1_1444068533.jpg','aprove' => 'yes','pname' => '','psname' => '','pgender' => '','pmarital' => '','plocation' => '','phobbies' => '','pabout_myself' => '','pdob' => '0000-00-00'), array('ID' => '2','Username' => 'AKA IV LEAGUE','mxitid' => 'm61831903002','mxitlogin' => '1998xtreme25','nick' => 'king"othello','phone' => 'ZTE/V795','location' => 'ZA,,,,,,212881,29608915838,1387f57','rank' => '2','registered' => '1443555418','last_online' => '1446731775','ip1' => '1c6ff112add9dc7a5594dec967be0f7a','ip2' => '196.35.255.31','pprofilepic' => 'images/resized_2_1446642825.jpg','aprove' => 'no','pname' => 'Akaworldwide','psname' => '','pgender' => 'Male','pmarital' => 'Not Saying','plocation' => 'South Africa »»KZN»»Durban','phobbies' => 'Programming - watching & playing soccer ','pabout_myself' => 'Humble guy down to earth- also short tempered - so watch what to say to me:)','pdob' => '1998-03-25'), And here is my Code I put together so far but not sure if im on the right track. <? $result9 = mysql_query("SELECT * FROM Users2 WHERE last_online < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 30 DAY))"); while($row = mysql_fetch_array($result9)){ $ppic = $row['pprofilepic']; $id = $row['ID']; $unlink($ppic); $query = "DELETE FROM Users2 WHERE ID ='".$id."'"; mysql_query($query); } ?>
  23. Hi, I'm going crazy with the following issue. I kept it simple for you to understand it quickly. The URL: http://localhost/savescores.php?score=222 <?php $score = strip_tags(mysql_real_escape_string($_GET['score'])); ECHO "Test 1"; ECHO "<h1>Your score is " . $_GET["score"] . "</h1>"; //Working! ECHO "Test 2"; ECHO "<h1>Your score is $score</h1>"; //Not working! ?> So the first echo test is working but its gets the information in another way as you can see. I need the second test to work because then I will be able to write the variable back into a database using url vars on a later stage. When I change the var $score manually to e.g. $score = '222'. Then all is working fine. I need it to work with the use of the URL. Anyone who can help?
  24. Hi I'm trying to recall a list of names of people who posted something according to the StringyChat_time field within the hour. The problem is it doesn't select the latest record, but rather the oldest one within the hour how can I select the latest time record? $galleries = array('ADMIN','Moderator','Global Helper','Helper','!!!ANNOUNCEMENT!!!','!!!TOPIC CHANGE!!!'); $sql = "SELECT * FROM StringyChat WHERE StringyChat_time >= (UNIX_TIMESTAMP() - 3600) AND StringyChat_name NOT IN ( '" . implode($galleries, "', '") . "' ) GROUP BY StringyChat_name ORDER BY StringyChat_time DESC LIMIT $offset, $rowsperpage"; $result1 = mysql_query($sql, $db)or die($sql."<br/><br/>".mysql_error());
  25. I do have a `.dat` file that contain airports data all around the world. So now I need to insert data into `mysql` from this `.dat` file. This is how I tried it in mysql: LOAD DATA LOCAL INFILE '/tmp/airports.dat' REPLACE INTO TABLE airports FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' (apid, name, city, country, iata, icao, y, x, elevation, timezone, dst, tz_id); But its not inserting data into mysql and I can get an error when I run above query. mysql> LOAD DATA LOCAL INFILE '/tmp/airports.dat' REPLACE INTO TABLE airportsFIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' ( apid, name, city, country, iata, icao, y, x, elevation, timezone, dst, tz_id); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' (apid, nam' at line 1 mysql> This is the data structure of my `.dat` file: 1,"Goroka","Goroka","Papua New Guinea","GKA","AYGA",-6.081689,145.391881,5282,10,"U","Pacific/Port_Moresby" 2,"Madang","Madang","Papua New Guinea","MAG","AYMD",-5.207083,145.7887,20,10,"U","Pacific/Port_Moresby" 3,"Mount Hagen","Mount Hagen","Papua New Guinea","HGU","AYMH",-5.826789,144.295861,5388,10,"U","Pacific/Port_Moresby" 4,"Nadzab","Nadzab","Papua New Guinea","LAE","AYNZ",-6.569828,146.726242,239,10,"U","Pacific/Port_Moresby" 5,"Port Moresby Jacksons Intl","Port Moresby","Papua New Guinea","POM","AYPY",-9.443383,147.22005,146,10,"U","Pacific/Port_Moresby" 6,"Wewak Intl","Wewak","Papua New Guinea","WWK","AYWK",-3.583828,143.669186,19,10,"U","Pacific/Port_Moresby" 7,"Narsarsuaq","Narssarssuaq","Greenland","UAK","BGBW",61.160517,-45.425978,112,-3,"E","America/Godthab" 8,"Nuuk","Godthaab","Greenland","GOH","BGGH",64.190922,-51.678064,283,-3,"E","America/Godthab" 9,"Sondre Stromfjord","Sondrestrom","Greenland","SFJ","BGSF",67.016969,-50.689325,165,-3,"E","America/Godthab" 10,"Thule Air Base","Thule","Greenland","THU","BGTL",76.531203,-68.703161,251,-4,"E","America/Thule" And so on upto 8000 of lines. Hope somebody may help me out. Thank you.
×
×
  • 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.