1. Why isn't this working?

    Date: 06/24/05 (PHP Community)    Keywords: mysql, sql

    I have this line on one page..

    $update_totals = "UPDATE stock SET qty = $add, count = $newtotal WHERE barcode = $barcode";
    $update = mysql_query($update_totals, $connect);


    ..and it works fine. I have an if statement echoing "success, bla bla.." if it works and it's great. So why is it that this:

    $update_details = "UPDATE stock SET barcode = $barcode, prod_code = '$prodcode', printer_model = '$print_mod', desc = '$type', qty = $qty, count = $count, colour = '$colour', order_level = $reorder WHERE barcode = $old_bcode";
    $update_qry = mysql_query($update_details, $connect);


    ..doesn't work? What am I missing/not doing?

    RESOLVED thanks everyone :)

    Source: http://www.livejournal.com/community/php/312514.html

  2. Some background help with PHP + API, SOAP, XML

    Date: 06/27/05 (PHP Community)    Keywords: php, mysql, xml, sql

    I am a novice PHP scripter. I have done most of my work with PHP and MySQL, and PHP alone, but now a client is asking me to work with his API and SOAP. I am also a XML beginner.

    I admit, this stuff sounds a little scary. I was wondering if working with his API will be (shoulkd be) as easy as working with PHP's MySQL functions? Am I making the right analogy? I see PHP has some XML functions, too. When the client says I will "parse the XML" and pull the info out of it, will I be searching it for a string/pattern?

    I am a bit clueless and trying to do some research before I talk to him again. If you guys have any sites that you recommend for PHP use with API, SOAP and XML (or even a book), I would appreciate it the info.

    Source: http://www.livejournal.com/community/php/312940.html

  3. Optimising MySQL

    Date: 06/28/05 (PHP Development)    Keywords: mysql, database, sql, google

    I'm working on a site at the moment and I'm trying to optimise the MySQL queries, to place less of a strain on the server and make generally neater code. I'm currently using this technique to pull the last 10 topics flagged as news from the database:

    $query = mysql_query( "SELECT * FROM frm_topics t WHERE t.tpc_news = '1' AND t.tpc_news_mod_id > 0 ORDER BY t.tpc_sticky DESC, t.tpc_time DESC LIMIT 10", $_GLOBALS[ 'sql' ] );


    Then in the loop created by $results = mysql_fetch_array( $query ) using a second query to pull the content of the post:

    $news_sql = mysql_query( "SELECT * FROM frm_posts p WHERE p.pst_tpc_id = '".$results[ 'tpc_id' ]."' ORDER BY pst_time ASC LIMIT 1", $_GLOBALS[ 'sql' ] );


    Now, although this works, it currently uses 11 queries, plus various others I'm using to create each page; so I'm trying to find a neater solution. I've tried some tutorials on sub-queries found on Google, to no avail. The following works if there's only one news topic but falls over if there's more:

    $query = mysql_query( "SELECT * FROM frm_posts p, frm_topics t WHERE p.pst_tpc_id = ( SELECT tpc_id FROM frm_topics t WHERE t.tpc_news = '1' AND t.tpc_news_mod_id > 0 ORDER BY t.tpc_sticky DESC, t.tpc_time DESC LIMIT 10 ) AND t.tpc_id = p.pst_tpc_id ORDER BY p.pst_time ASC LIMIT 1", $_GLOBALS[ 'sql' ] );


    I'd really appreciate it if anyone could lend a hand or point me in the right direction.

    Source: http://www.livejournal.com/community/php_dev/59389.html

  4. Deleteing from multiple tables

    Date: 06/28/05 (MySQL Communtiy)    Keywords: mysql, sql

    I have 6 tables, all with a column called "projid" in them. I need to create a delete statement that will delete all rows in all columns where the projid is a specified number. I've read the MYSQL docs on this topic, but I'm still mightily confused. What I think I need is something like this:

    DELETE FROM projecttable, collabtable, miletable, stafftable, benetable, invtable
    WHERE projid=32


    However, I'm fairly certain that the WHERE statement isn't right, and I'm not sure if I need to put the table names after the delete as well as after the FROM, or only one place, or what. Can anyone either explain the syntax I need or point me to a tutorial or something that will help?

    Source: http://www.livejournal.com/community/mysql/60657.html

  5. Creating a table dynamically

    Date: 06/29/05 (PHP Community)    Keywords: php, mysql, database, sql

    I'm running this bit of PHP script in a page I'm writing for a real estate's site:
    $query = "CREATE TABLE 'mls" . $mls . "' ('id' INT NOT NULL AUTO_INCREMENT,'photo' VARCHAR(50) NOT NULL, PRIMARY KEY ('id'))";
    $result = mysql_query($query) or die("Query failed : " . mysql_error());

    The idea is that it's supposed to create a table named using a variable in the database. I would like to be able to dynamically create and drop tables as real estate listings are added and deleted. I just tried it out and it didn't work. No errors but the table didn't appear in the db when I went to look using phpMyAdmin. Is there something wrong with my code or is what I'm trying to do not possible?

    Source: http://www.livejournal.com/community/php/313804.html

  6. Creating a table dynamically

    Date: 06/29/05 (Web Development)    Keywords: php, mysql, database, sql

    I'm running this bit of PHP script that I'm writing:
    $query = "CREATE TABLE 'mls" . $mls . "' ('id' INT NOT NULL AUTO_INCREMENT,'photo' VARCHAR(50) NOT NULL, PRIMARY KEY ('id'))";
    $result = mysql_query($query) or die("Query failed : " . mysql_error());

    The idea is that it's supposed to create a table named using a variable in the database. I would like to be able to dynamically create and drop tables as real estate listings are added and deleted. I just tried it out and it didn't work. No errors but the table didn't appear in the db when I went to look using phpMyAdmin. Is there something wrong with my code or is what I'm trying to do not possible?

    Source: http://www.livejournal.com/community/webdev/216628.html

  7. Failure of PHP to work with Apache / MySQL

    Date: 07/03/05 (PHP Community)    Keywords: php, mysql, sql, google, apache

    I turned on my computer last night and found that PHP was refusing to communicate with MySQL - I could make MySQL work through the command line and through Perl, but not through PHP. I checked everything that I could think of and everything I could find on google without any joy. I have spent about 8 hours messing with this now and I'm getting nowhere. I've uninstalled and reinstalled php & mod_php so many times today that I've lost count. My latest idea was to uninstall php, mod_php, and apache. I've reinstalled Apache, php, and mod_php (in that order) but now PHP refuses to work with Apache. I've added APACHE2_OPTS="-D PHP5" to the apache config in /etc/conf.d/apache2 but it hasn't made any difference.

    I'm running Gentoo with Apache 2.0.54, PHP 5.0.4 (along with mod_php 5.0.4), and MySQL 4.0.24.

    Does anyone have any ideas how I can make it work again as I'm going insane here and feel like throwing the computer out of the window...

    Source: http://www.livejournal.com/community/php/314431.html

  8. PHP/MySQL Import

    Date: 07/03/05 (PHP Community)    Keywords: php, mysql, sql, web

    I have a dump file on the web server. How do I do a mysql import of that file. It's over 2MB and I can't use phpmyadmin because of that.

    Source: http://www.livejournal.com/community/php/314649.html

  9. Logs? Admin Question...

    Date: 07/05/05 (MySQL Communtiy)    Keywords: mysql, sql, google

    I find these files named:

    [servername]-bin.001, .002, .003, etc in my mysql folder. They look like logs, is that what they are? How can I make mysql _not_ produce them? Any assistance or pointing in the right direction would be greatly appreciated. I did try to google it, but got nothing.

    Source: http://www.livejournal.com/community/mysql/61051.html

  10. Gah.

    Date: 07/08/05 (WebDesign)    Keywords: php, mysql, html, asp, sql

    Hope this isn't a bother.

    I'm trying to find a random quote generator that uses HTML or PHP. If it's possible to do it without MySQL, ASP, etc etc etc. Anybody? Beuller?

    Rock on. <3 

    Source: http://www.livejournal.com/community/webdesign/924390.html

  11. Help creating a query

    Date: 07/11/05 (PHP Community)    Keywords: php, mysql, sql

    I need some help with a query I'm trying to create to send to MySQL. The problems are on the PHP side, so I'm posting here rather than at '[info]'mysql.

    I have an array of starting letters. I'm trying to select all projects that start with a letter in an array. The array will have at least one letter, possibly more.

    Here is the code that's causing me confusion:

    foreach ($startlet as $let){
       $sql.=" $projectcolumn[title] LIKE '".$let."%'";
    }


    I need to put an OR in there at the end of every line but the last. Is there an easy way to do this, or am I going to need to get the length of the array, then iterate some number and compare? I'm fine with a different control structure, but I couldn't find anything that would easily and simply do what I want. Is there one, or am I just going to have to be satisfied with complex?
    Edit: Never mind
    Figured I could do it this way. Maybe not so pretty, but functional.
    $i=0;
    	while ($i<(count($startlet)-1)){
    		$sql.=" $projectcolumn[title] LIKE '".$startlet[$i]."%' OR";
    		$i++;
    	}
    	$sql.=" $projectcolumn[title] LIKE '".$startlet[$i]."%'";

    Source: http://www.livejournal.com/community/php/317164.html

  12. Understand Error messages

    Date: 07/13/05 (PHP Community)    Keywords: mysql, sql

    I am using echo mysql_error(); to help debug my code.

    Would this statement return

    "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"

    if there were no records that matched the query?

    Source: http://www.livejournal.com/community/php/318263.html

  13. SQL Injection

    Date: 07/14/05 (PHP Community)    Keywords: php, mysql, sql

    Whenever I've got a mysql query and the user is inputting something in a feild (let's just say for example a login page), I add addslashes to every GET and POST request. Is there anything else I can do to protect myself from sql injection? I'm fairly new to mysql so I'm not entirely sure of all of its commands and what not. I thought it would be appropriate to post this in a PHP community, though, because everything that I would have to worry about is in my php coding.

    Any help is greatly appreciated.

    Source: http://www.livejournal.com/community/php/318792.html

  14. Choices for a flexible CMS

    Date: 07/17/05 (WebDesign)    Keywords: cms, php, mysql, database, sql

    I know, another "what CMS should I use?" question. But hear me out. I'm looking for a CMS that's flexible, easy to set up, allows all users to submit content, and has some sort of mechanism for reviewing items (like Epinions or Amazon or Yelp.)

    I can run PHP (safe mode only) or Perl, and I've got a MySQL database.

    Any suggestions? Please?

    Source: http://www.livejournal.com/community/webdesign/930368.html

  15. Photo Gallery Scripts?

    Date: 07/18/05 (PHP Community)    Keywords: php, mysql, database, sql

    Anyone know of any photo gallery scripts that will do the following?

    1. Show a preview for each category.

    2. Randomize a the preview from each category.

    3. Allow a single image to be included in multiple categories.

    I'm working with a team that is going to eventually do this in flash with an animation and such but they asked if I could do this in php in the meantime and they'll integrate the flash my php later. I'm a PHP/MySQL database guy so this is new to me...

    Source: http://www.livejournal.com/community/php/320514.html

  16. returning data from newly inserted row in a mysql table

    Date: 07/18/05 (PHP Community)    Keywords: mysql, sql

    is there a function that returns data from newly inserted rows in a mysql table? i have a table i'm inserting rows into, with an auto-incrementing id field. that id is used as a foreign id in another table which i need to insert rows into immediately after. a simple version might look like this:

    \USERS\
    id | name
    1 | tom
    2 | jen
    3 | sam

    \NOTES\
    id | foregn_id | note
    1 | 1 | note for tom
    2 | 1 | note for tom
    3 | 1 | note for tom
    4 | 2 | note for jen
    5 | 3 | note for sam

    $sql = "INSERT INTO users (name) VALUES ('bob')";
    mysql_query($sql);

    so now in the users table we'll probably get

    4 | bob

    and immediately after in the script i'd need to do

    $sql = "INSERT INTO notes (foreign_id,note) VALUES (4,'note for bob')";
    mysql_query($sql);

    what i'm doing now is constructing a query that finds the id for 'bob', then using it in the follow-up query. so, in total, we'd have

    $sql = "INSERT INTO users (name) VALUES ('bob')";
    mysql_query($sql);
    $sql = SELECT * FROM users WHERE name = 'bob';
    $id = mysql_result(mysql_query($sql),0);
    $sql = "INSERT INTO notes (foreign_id,note) VALUES ($id,'note for bob')";
    mysql_query($sql);

    except my code is far messier because i'm dealing with more fields and more data. which brings us back to my original question! is there a cleaner way to get the id of the row i just inserted?

    Source: http://www.livejournal.com/community/php/320911.html

  17. Lame Nerd Question

    Date: 07/20/05 (Computer Geeks)    Keywords: php, mysql, sql, web, linux, hosting, apache

    Here's what's happening:

    My company seems to be dragging its feet on upgrading the Solaris server on which I'm supposed to be running this website I'm developing. I've been hosting on my own external server, and when this summer internship is over, I have to move everything over regardless of whether or not the server is ready.

    Consequently, people in my department are trying to hunt down an extra Unix box for me to use as a pseudo-server until the real server is (finally) upgraded.

    So here's my question:

    I've only touched Unix very remotely, as in using an SSH command-line console with my school's web server. I'm a little familiar with basic Linux commands, but that's about it. How difficult would it be for someone like me (who only uses Linux when she has to for classes) to install Apache, PHP, and MySQL...as well as migrate over my existing website (currently running on a Red Hat 9 server with Apache, PHP 4.x, and MySQL 3.2.3 or something similar)?

    Any info would be greatly appreciated.

    Source: http://www.livejournal.com/community/computergeeks/730050.html

  18. mysql questions

    Date: 07/20/05 (PHP Community)    Keywords: mysql, html, sql

    http://www.livejournal.com/community/mysql/62230.html

    i posted about a little mysql issue i'm working out over in '[info]'mysql

    any of you mysql-heads that want to give me some advice, have at it

    Source: http://www.livejournal.com/community/php/322672.html

  19. Time handling problem

    Date: 07/21/05 (PHP Community)    Keywords: mysql, sql

    I want to report back to the user how long it's been since their last login. I'm having a problem processing the time, though.

    $query = "SELECT DATE_FORMAT(date_last,'%c-%d-%Y %k:%i:%S') dl, 
    DATE_FORMAT(NOW(),'%c-%d-%Y %k:%i:%S') dn FROM people WHERE 
    (user_id=$id AND password=PASSWORD('$pass') )";
    $result = mysql_query($query);
    if (mysql_num_rows($result)==1) {
        while ($row=mysql_fetch_array($result)) {
            $lasttime = $row['dl'];
            $nowtime = $row['dn'];
            $timediff = round((strtotime($nowtime) - strtotime($lasttime)) / (60*60));
            echo "You last logged in $timediff hours ago.";
        }
    }
    

    Here is what I get:
    // $nowtime == string(18) "7-21-2005 10:51:40"
    // strtotime($nowtime) == int(1393429900)
    // $lasttime == string(18) "7-20-2005 21:21:59"
    // strtotime($lasttime) == int(1390789319)
    You last logged in 733 hours ago 
    

    I had understood that strtotime() will parse GNU standard date formats into seconds, so I had assumed multiplying the difference in dates by 1200 would get the difference in hours.

    I don't understand why I'm getting 733 hours offset instead of 13. Can anybody tell me what I've got wrong here?
    Edit: A saner MySQL query does the trick. Thanks to those who helped.

    Source: http://www.livejournal.com/community/php/323703.html

  20. Possible web development job/need to learn PHP

    Date: 07/23/05 (Web Development)    Keywords: php, mysql, sql, web

    Yesterday I had an interview at a great web design firm here. The interview went great, and I'm going back in on Tuesday for a second interview. One of the only things that was a "negative mark" for me was that I don't know how to code in PHP (I know, I know..."get with the times dumbass!"), however, I learn incredibly fast and I decided after the interview that I would make sure I have a solid understanding of the language before I go into the second interview on Tuesday.

    I spent all day yesterday reading books and web sites about PHP and MySQL and I'm already able to write relatively simple scripts without relying on references. What I'm looking for now are web sites that have something more intermediate that I could try my hand at (as opposed to the basic lessons most websites give...which are typically based around the same concepts). I've found that I usually learn better when I get the basics of a language down and then jump into stuff a bit over my head...struggling makes me try harder and helps things stick in my head.

    Anyone know of a website or two with good, advanced PHP lessons?

    Source: http://www.livejournal.com/community/webdev/224748.html

Previous page  ||  Next page


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home