premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
lol I have the time and know exactly what to do. But I do not believe in doing one's homework. Read the book, talk to your teacher get a study group with other students. Being proactive in class is your only hope, sad enough.
-
Yep give it a try and see for yourself. Alternative, since you are using the same data more than once. Why not do this: $inArray = array('', '$-', '0', '0.0', '0.00', '$ 0', '$ -', '$0.0', '$0.00', '-', ' ', '$'); $checkData = implode("', '", $inArray); mysql_query("DELETE FROM {$tablename} WHERE $dealer IN({$checkData}) OR $distributor IN({$checkData}) OR $list IN({$checkData})"); A tad bit more user friendly/easier.
-
[SOLVED] Generating delimited csv data with php
premiso replied to c_shelswell's topic in PHP Coding Help
I have my days -
Make the columns $dealer, $distributor and $list indexes in the table structure. This will index them and should speed up the process. As a side note, you can combine those three queries into using ($dealer IN()) OR ($distributor IN()) OR ....
-
Along side that here is a corrected version, you need to use " around values in html or you get errors: <OPTION VALUE="<?php echo "$productID, $assesmentLimit"; ?>"> <?php echo "$productID $assesmentLimit"; ?></OPTION> And it is also good practice to have the </option> Not required, just good practice.
-
You are trying to print an object like it is a string. $obj = new fetchValue(global_header, header_content)); echo $obj->__toString(); Should work. Either way calling that object returns the object, even with the tostring method. You have to call it like a method/function to get the function to return what it is suppose to return.
-
function call error... (using PEAR MDB2 library)
premiso replied to qmqmqm's topic in PHP Coding Help
$result = $connection->query(); You are missing the $query parameter....you need to put $query_string inside that. -
[SOLVED] Generating delimited csv data with php
premiso replied to c_shelswell's topic in PHP Coding Help
Why not open excel add a few records with commas then export it as a csv and see how they handle commas. They may have an escape character you need to add. -
stristr would be the way to do it. You would have to loop through the array to check however.
-
if(stristr($myAr[$i], ".jpg") !== false){ stristr should fix that for you.
-
[SOLVED] TWO WEEKS AND STILL NO ANSWER ON THIS ONE!!
premiso replied to medaswho's topic in PHP Coding Help
Should have been solved a bunch of posts ago. -
[SOLVED] TWO WEEKS AND STILL NO ANSWER ON THIS ONE!!
premiso replied to medaswho's topic in PHP Coding Help
Can you post data in your table, like 5-10 rows, and your table structure for us? And what you are getting returned the "random data". -
[SOLVED] TWO WEEKS AND STILL NO ANSWER ON THIS ONE!!
premiso replied to medaswho's topic in PHP Coding Help
No, he means the $_POST data. As that can change, are you sure it is being populated and the data coming into that is what you expect it. Maybe echo the $_POST['sname'] out on the page to make sure that contains what you expect it. -
[SOLVED] TWO WEEKS AND STILL NO ANSWER ON THIS ONE!!
premiso replied to medaswho's topic in PHP Coding Help
It should not, it would be a glitch. However, if you have duplicate screennames in the DB, this may happen, especially if you do not have a primary key set on the table which is an id, or a unique value. My bet is, the post data is causing the issue. Could be you need to trim it, or it is not posting when you think it is etc. Try this as your page and see what happens: <?php session_start(); if (isset($_POST['sname'])) { // get the variables from the login form $sname = $_POST['sname']; $pass = $_POST['pass']; mysql_connect($host,$user,$password); mysql_select_db($dbname); $result = mysql_query("SELECT * FROM members WHERE screenname = '$sname' ") or die(mysql_error()); while ($row1 = mysql_fetch_row( $result )) { echo $row1['0']."<br>"; echo $row1['1']."<br>"; echo $row1['2']."<br>"; echo $row1['3']."<br>"; echo $row1['4']."<br>"; echo $row1['5']."<br><br>"; } } ?> And just so you do realize that mysql randomizing data output is not normal, but given that I do not know how your tables are setup it is a possibility. phpMyAdmin most likely sorts the data by an ORDER BY to prevent this randomization, but yea. EDIT: Major edit, had to remove the ! from the isset beginning as that was completely wrong. -
Yea, it is confusing. However, the problem with unix timestamps is that they have a limitation of 2038, vs the mysql datetime does not. Just so you know, if trying to go past that date you will get issues using time stamps.
-
Its a 404 cause that page does not exist. http://www.phpfreaks.com/tutorials Is the correct link.
-
[SOLVED] TWO WEEKS AND STILL NO ANSWER ON THIS ONE!!
premiso replied to medaswho's topic in PHP Coding Help
Sorry, this just does not make sense to me. You are meaning to fetch one record. The code you have can sometimes fetch one record, given the sname or sometimes fetch a completely different record of the sname? Do you have multiple records that have the sname? Maybe it is randomizing output, which it should not but is a possibility. There is nothing in your code that could be doing this? How are you testing the pulling of data with the query? There are a ton of unknowns and with us not knowing how experienced you are with php and mysql. MySQL is not a guessing game, honestly. It returns what input you give it. Is this the full code you are executing? Can you print out the table data (if less than 10 rows) and print out one of the queries you can run in phpMyAdmin and what it returns? Then what does that same query return, using a loop, in your code.... There are a ton of scenarios here and yea. It is basically a needle in the haystack, however to find this needle you just need to provide us with a bit more detailed information. EDIT: Could it be directly related to the POST data not coming through? Are you checking if a form was submitted and not just assuming that data is there? -
Why not compare it in mysql? You can use strtotime to convert the date in mysql to unix timestamp and compare it, alternatively you can use date to format the date to mysql format date('Y-m-d')
-
[SOLVED] TWO WEEKS AND STILL NO ANSWER ON THIS ONE!!
premiso replied to medaswho's topic in PHP Coding Help
Your not looping the data. while($row1 = mysql_fetch_row( $result )) { echo $row1['0']."<br>"; echo $row1['1']."<br>"; echo $row1['2']."<br>"; echo $row1['3']."<br>"; echo $row1['4']."<br>"; echo $row1['5']."<br>"; } Should give you all the data that your query is setup to return (given that you limit it with the $_POST['sname']). -
It sounds like you do not have the mysql extension installed via php. You have to either uncomment that line in the php.ini and/or install that extension. Should be as simple as uncommenting, saving then restarting apache.
-
If they are separated by an item explode would split them into an array. EDIT: Not sure if you wanted the "email" to be returned as an array (like a single email) if so I believe str_split is what you would be after.
-
Turn on display_errors ini_set('display_errors', 1); to give you error messages. as to why it is not working, your code looks sound to me, no syntax issues. Also mysql_close is not needed, the connection is closed when the page has finished executing. Try this as well: <?php echo 'Attempting a connection'; $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; ?> And see what you get back.
-
$sql = "SELECT x.item, h.productid FROM xdata x, hdata h WHERE x.item NOT IN(SELECT products_model FROM my_products) OR h.productid NOT IN(SELECT products_model FROM my_products)"; Dunno if that will work. If it does there is probably a better way to do it. As to how, I do not know.
-
You could just use the IN statement and have 1 query: mysql_query("DELETE FROM {$tablename} WHERE $dealer IN('', '$-')"); Just add the rest to that IN statement following the same format.
-
[SOLVED] Fetching Variable Data From External Websites E.g. Ebay
premiso replied to programguru's topic in PHP Coding Help
Yep entirely possible. You should look into: curl As for the technical term: Web Fetching.