premiso
Members-
Posts
6,951 -
Joined
-
Last visited
-
Days Won
2
Everything posted by premiso
-
That is fine. As long as you do it with each person logging in it should not be too bad. But for the first person to login in the morning it may take it a while to update the DB etc. You may limit that query to 10 or 20, so it does not take a huge toll on 1 particular user and it spreads it among many.
-
[SOLVED] MYSQL Select minus 6 hours, SQL working but not in PHP.
premiso replied to PHPKevin's topic in PHP Coding Help
Why not try to query it via phpMyAdmin with the where clause in? I saw up above you said you did it without the where clause...that is why it returns 2 results. The where clause is limiting it. So run it through phpMyAdmin with that where clause and then modify it that way before you venture into getting it to work in PHP. If you cannot even get it to work in PHPMyAdmin WITH the where clause then it will never work in PHP with the where clause. -
You are closing the tble too early. Put the </table> after the php and before the </body> Viewing the source of the page would have yielded the problem.
-
[SOLVED] only showing a value if it equals something?
premiso replied to shadiadiph's topic in PHP Coding Help
Weird... Well as long as it works I guess that is all you can ask for. I just figured it would throw a header error since you printed the data but yeah. -
[SOLVED] How do I get the result of this Mysql Query?
premiso replied to alexville's topic in PHP Coding Help
$a = mysql_query("SELECT SUM(`views`) FROM games WHERE uploader = '$session->username'"); $views = 0; if (mysql_num_rows($a) > 0) { $views = mysql_fetch_array($a); $views = $views[0]; if (empty($views) || $views == "") $views = 0; } echo $views; Try that. It is simple if logic.... -
[SOLVED] How do I get the result of this Mysql Query?
premiso replied to alexville's topic in PHP Coding Help
$a = mysql_query("SELECT SUM(`views`) FROM games WHERE uploader = '$session->username'"); $views = 0; if (mysql_num_rows($a) > 0) { $views = mysql_fetch_array($a); $views = $views[0]; } echo $views; -
[SOLVED] only showing a value if it equals something?
premiso replied to shadiadiph's topic in PHP Coding Help
No you need the exit. Without the exit it will always execute the no-image portion also. The whole point of the exit is so you can get rid of the else and if the script reaches the end of the page that means the correct conditions were not met. You need the exit in there. -
[SOLVED] How do I get the result of this Mysql Query?
premiso replied to alexville's topic in PHP Coding Help
mysql_result, mysql_fetch_array, mysql_fetch_row.....etc etc. -
[SOLVED] only showing a value if it equals something?
premiso replied to shadiadiph's topic in PHP Coding Help
According to that statement, what is happening is there is that pic for showpic4. Check the data in the database for the ID you are passing. I took the else out to avoid duplicate data, that should work like expected if there is no image returned by the SQL Query. But obviously there is data being returned by the SQL Query. But I think I am understanding what you want to do. <?php require("global/admin_functions.php"); if (isset($_GET['adid'])) { $query = "SELECT thumbnail3,thumbnailtype3 FROM zloads where intProductID=".$_GET['adid']; $result = mysql_query($query); if (mysql_num_rows($result) > 0) { $data = mysql_result($result,0,"thumbnail3"); if (!empty($data) && $data != "") { $type = mysql_result($result,0,"thumbnailtype3"); Header( "Content-type: $type"); print $data; exit; } } } header("Content-Type: image/png"); $file = ('../pix/noimage.png'); $source = (fread(fopen($file, "r"), filesize($file))); print ($source); ?> Adding that if in there should test if that image has been set or not. Also you know you could consolidate this into 1 file instead of 4 or 5 different by doing this <?php require("global/admin_functions.php"); $thumbnailNum = isset($_GET['type'])?$_GET['type']:1; // default to 1 if no value if (isset($_GET['adid'])) { $query = "SELECT thumbnail" . $thumbnailNum . ",thumbnailtype" . $thumbnailNum . " FROM zloads where intProductID=".$_GET['adid']; $result = mysql_query($query); if (mysql_num_rows($result) > 0) { $data = mysql_result($result,0,"thumbnail" . $thumbnailNum); if (!empty($data) && $data != "") { $type = mysql_result($result,0,"thumbnailtype" . $thumbnailNum); Header( "Content-type: $type"); print $data; exit; } } } header("Content-Type: image/png"); $file = ('../pix/noimage.png'); $source = (fread(fopen($file, "r"), filesize($file))); print ($source); ?> Then just add type=x where x is 1 2 3 4 etc.... Let me know how that works. -
[SOLVED] only showing a value if it equals something?
premiso replied to shadiadiph's topic in PHP Coding Help
Sorry I feel like an idiot. Try this: <?php require("global/admin_functions.php"); if (isset($_GET['adid'])) { $query = "SELECT thumbnail3,thumbnailtype3 FROM zloads where intProductID=".$_GET['adid']; $result = mysql_query($query); if (mysql_num_rows($result) > 0) { $data = mysql_result($result,0,"thumbnail3"); $type = mysql_result($result,0,"thumbnailtype3"); Header( "Content-type: $type"); print $data; exit; } } header("Content-Type: image/png"); $file = ('../pix/noimage.png'); $source = (fread(fopen($file, "r"), filesize($file))); print ($source); ?> Changed < 1 to > 0 in the mysql_num_rows part. -
[SOLVED] only showing a value if it equals something?
premiso replied to shadiadiph's topic in PHP Coding Help
I know that some servers <?= is disabled so it is good practice to use <?php echo $id; ?> instead. Not sure if that is the issue, but are you sure that $id is being populated from the database? Post the code where the $id is being set, like that whole section of code. -
[SOLVED] only showing a value if it equals something?
premiso replied to shadiadiph's topic in PHP Coding Help
It sounds to me like you are not populating the adid. That is why you are not getting the image. http://www.yoursite.com/showpic3.php?adid=x Replace the x with the product id and see what comes out. As long as that has a value and the productid does indeed have a pic inside it should display just fine. -
write a query to insert an array with vary size each time into MySQL
premiso replied to phppaper's topic in PHP Coding Help
Gotcha. <?php $values = implode("', '", $array); mysql_query("INSERT INTO table VALUES (" . $values . ")"); ?> Simple as that. -
[SOLVED] only showing a value if it equals something?
premiso replied to shadiadiph's topic in PHP Coding Help
<?php require("global/admin_functions.php"); if (isset($_GET['adid'])) { $query = "SELECT thumbnail3,thumbnailtype3 FROM zloads where intProductID=".$_GET['adid']; $result = mysql_query($query); if (mysql_num_rows($result) < 1) { $data = mysql_result($result,0,"thumbnail3"); $type = mysql_result($result,0,"thumbnailtype3"); Header( "Content-type: $type"); print $data; exit; } } header("Content-Type: image/png"); $file = ('../pix/noimage.png'); $source = (fread(fopen($file, "r"), filesize($file))); print ($source); ?> Try that. You should not query if $_GET does not have a variable in it. I would also do some data validation on the $_GET before using it in my query, but that is me. -
write a query to insert an array with vary size each time into MySQL
premiso replied to phppaper's topic in PHP Coding Help
thanks but thats not related to my question So let me get this straight. You want to loop through the array and insert the values into it? Before I waste my time writing an example code you need to show me the full array structure and how it needs to be entered. Either do a print_r on the array you want to insert and paste it here or write it out on your own. Providing us with what you actually want is the key to getting your questioned answered without all this going back and forth with me just needing more basic information. -
write a query to insert an array with vary size each time into MySQL
premiso replied to phppaper's topic in PHP Coding Help
serialize Make the DB field a text and use that function above. When retrieving it from a DB use unserialize -
[SOLVED] MYSQL Select minus 6 hours, SQL working but not in PHP.
premiso replied to PHPKevin's topic in PHP Coding Help
I would think your DISTINCT * is throwing it off. I think you need to define a single column for DISTINCT cause if you have a time field, which I know you do, any time that matches up will not be returned more than once. What column should be distinct? -
It's not just you trust me. I could spend hours looking at my own code and miss something that small and I should have caught in the first 5 seconds of looking at it. That is just how your mind works. Sometimes printing the problem code on paper helps too.
-
[SOLVED] only showing a value if it equals something?
premiso replied to shadiadiph's topic in PHP Coding Help
Then that means you have an error in your query. <?php require("global/admin_functions.php"); $query = "SELECT thumbnail3,thumbnailtype3 FROM zloads where intProductID=".$_GET['adid']; $result = mysql_query($query) or die(mysql_error()); if (mysql_num_rows($result) > 0) { That is how it should be, run that and I bet you get an error in SQL query. If you need help to fix that post the error. If not fix it and it should work just fine. -
The flash application should not care where the MP3 file is located. I am not sure how that software works etc, but yea should be possible. However if you want them to be able to download it you may want to store the mp3s with a randomly generated hash for the file name, then use the DB to have them download with the original name etc. At least that is my 2 cents. But yea the flash player should not care where the MP3 is as long as you give it the correct path.
-
$result = mysqli_query($database->connection,$sql);
-
$get=mysql_query("SELECT ip FROM server1 WHERE IP='$ip'"); Should fix that problem. If you wanted to use single quotes inside single quotes you have to escape them. Simple as that.
-
If the site is not currently coded for it you will have to re-code the site. What you can do while you recode is put in language definitions and make them dynamic. What I do is store any phrase in a database with a column country, then when the script loads execute a query in a language file and pull out all the tables for that language and make them constants then just use those common constant names. Table would have: languageid, language, text, constantname Once that is done, you can add any language you want just by adding a selction option and writing out everything in that table for the new language. Hope that helps.
-
[SOLVED] moving a variable from one table to another
premiso replied to contra10's topic in PHP Coding Help
Where is the $_GET being set when you post the data? I do not see that anywhere... If you put it in a hidden field it would become $_POST instead of $_GET -
[SOLVED] moving a variable from one table to another
premiso replied to contra10's topic in PHP Coding Help
There cannot be a WHERE in the insert. You would use the UPDATE syntax to perform that. $insert = "UPDATE users SET mygroups = '$groupname' WHERE username = '$username'"; If you are indeed meaning to insert, the question is why are you trying to choose a specific username? Usually you insert their username in there. I think you meant update though.