nbarone
-
Posts
90 -
Joined
-
Last visited
Never
Posts posted by nbarone
-
-
fixed - source file needed a ".." in front of it. Found error as a PHP Warning in error log.
To Chris92... the extra parenthesis are not required, although good practice.
-
I am trying to load in a PNG image, and place a number on top of it. This code is not outputting anything (not even an error):
<?php // define base image $base = ($_GET['hover']=='true')?"/images/assets/sel_hover.png":"/images/assets/sel.png"; // create image $image = imagecreatefrompng($base); // define colors $black = imagecolorallocate($image, 0, 0, 0); // text // define font file $font = "helvetica.ttf"; // define incremental number $num = $_GET['inc']; // define header header ("Content-type: image/png"); // write text to image imagettftext($image,10,0,3,3,$black,$font,$num); // display image imagepng($image); imagedestroy($image); ?>
-
Thanks, that worked great.
Sorry for the confusion, at first I thought it would be easiest to sort by length, but I figured I'd check and see if it's possible to sort by directory.
-
if(!isset($_GET['x'])){ // x is not valid } else { // x is valid }
-
Hi, I have a multidimensional array and I would like to sort it by the length of the first key.
The first key is a file path, the second key is a file id, and then several parameters under that.
$filelist['\\fileserver\share\path\to\file']['1234']['name'] = "video.avi";
If possible, I would like to sort the first key in a tree-like format
example:
$filelist['\\fileserver\share\'] = $filelist[0]
$filelist['\\fileserver\share\folder1'] = $filelist[1]
$filelist['\\fileserver\share\folder1\anotherfolder\'] = $filelist[2]
$filelist['\\fileserver\share\folder1\anotherfolder2\'] = $filelist[3]
$filelist['\\fileserver\share\folder2\'] = $filelist[4]
Also, I would like to story the filenames alphabetically
$filelist['\\fileserver\share\path\to\file']['1234']['name'] = "video.avi";
I don't know how I would do this all with such a complex array.
-
You're escaping the single quotation.. try changing \\fileserver01\SHARE01\VIDEO\DVD Files\2009 to \\fileserver01\SHARE01\VIDEO\DVD Files\2009\\
Thanks, that was the issue.
-
They are all datetime fields.
-
I'm hoping someone here will have a better eye at catching this error than I have.
Thanks in advance.
Actual code:
$sql = "INSERT INTO mfl_files (file_name, file_share, file_path, file_created, file_modified, file_lastVerified, file_active) VALUES ('$file', '$shr_id', '$dir', '$dateCreated', '$dateModified', '$newDateVer', '1')";
$sql output:
INSERT INTO mfl_files (file_name, file_share, file_path, file_created, file_modified, file_lastVerified, file_active) VALUES ('09-6-2009-dvd.mov', '1', '\\fileserver01\SHARE01\VIDEO\DVD Files\2009\', '2009-11-24 09:33:11', '2010-02-03 16:37:34', '2010-02-25 10:37:28', '1')
Error:
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 '2009-11-24 09:33:11', '2010-02-03 16:37:34', '2010-02-25 10:37:28', '1')' at line 2
-
You can't, sorry!
Best bet would be to make a small picture with the link to the page, then ask your users to "drag" the picture to the home icon in firefox/chrome.
-
\n is a "newline" characters, as in a line break or return.
that line replaces "\n" with "" (nothing), removing your issue.
-
well, I am a retard (most of my posts here end this way) - I removed the include('db.php') in the second page, which would explain all the issues. now it is running fine.
I will keep this here as a lesson learned
-
Well I have an include file that pulls a num_rows variable from the database.
I have this page included in a few different pages throughout the site - however, on just one page, it runs very slow.
here's the script:
<?php $foxridge[8] = 3; $foxridge[6] = 6; $alpine[8] = 10; $alpine[6] = 10; $valley[8] = 5; $valley[6] = 1; $inn[2] = 10; $inn[4] = 89; $wildflower[2] = 23; $wildflower[4] = 32; $wildflower[6] = 20; $snowpine[2] = 4; $snowpine[4] = 18; $snowpine[6] = 30; $snowpine[8] = 15; foreach($foxridge as $k=>$v){ $sql = "SELECT b_id FROM breakaway WHERE b_location='foxridge' AND b_numRoommates='".$k."'"; if(mysql_num_rows(mysql_query($sql)) >= $v) $foxridge[$k] = false; //echo "<br>Foxridge: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql)); echo date("H:i:s"); echo "<br>"; } foreach($alpine as $k=>$v){ $sql = "SELECT b_id FROM breakaway WHERE b_location='alpinemeadow' AND b_numRoommates='".$k."'"; if(mysql_num_rows(mysql_query($sql)) >= $v) $alpine[$k] = false; //echo "<br>Alpine: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql)); echo date("H:i:s"); echo "<br>"; } foreach($valley as $k=>$v){ $sql = "SELECT b_id FROM breakaway WHERE b_location='valleyvillage' AND b_numRoommates='".$k."'"; if(mysql_num_rows(mysql_query($sql)) >= $v) $valley[$k] = false; //echo "<br>Valley: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql)); echo date("H:i:s"); echo "<br>"; } foreach($inn as $k=>$v){ $sql = "SELECT b_id FROM breakaway WHERE b_location='inn' AND b_numRoommates='".$k."'"; if(mysql_num_rows(mysql_query($sql)) >= $v) $inn[$k] = false; //echo "<br>The Inn: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql)); echo date("H:i:s"); echo "<br>"; } foreach($wildflower as $k=>$v){ $sql = "SELECT b_id FROM breakaway WHERE b_location='wildflower' AND b_numRoommates='".$k."'"; if(mysql_num_rows(mysql_query($sql)) >= $v) $wildflower[$k] = false; //echo "<br>Wildflower: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql)); echo date("H:i:s"); echo "<br>"; } foreach($snowpine as $k=>$v){ $sql = "SELECT b_id FROM breakaway WHERE b_location='snowpine' AND b_numRoommates='".$k."'"; if(mysql_num_rows(mysql_query($sql)) >= $v) $snowpine[$k] = false; //echo "<br>Snowpine: ".$k." - ".$v." - ".mysql_num_rows(mysql_query($sql)); echo date("H:i:s"); echo "<br>"; } $twos = true; $fours = true; $sixs = true; $eights = true; if(($snowpine[2]==false)&&($wildflower[2]==false)&&($inn[2]==false)){ $twos = false; } if(($snowpine[4]==false)&&($wildflower[4]==false)&&($inn[4]==false)){ $fours = false; } if(($snowpine[6]==false)&&($wildflower[6]==false)&&($valley[6]==false)&&($foxridge[6]==false)&&($alpine[6]==false)){ $sixs = false; } if(($snowpine[8]==false)&&($valley[8]==false)&&($foxridge[8]==false)&&($alpine[8]==false)){ $eights = false; } ?>
now it will output the timestamp of each query, so I can debug.
on one page it looked like this:
09:53:3209:53:32
09:53:32
09:53:32
09:53:32
09:53:32
09:53:32
09:53:32
09:53:32
09:53:32
09:53:32
09:53:32
09:53:32
09:53:32
09:53:32
on the page in question, it took about 1 second per query:
09:56:1409:56:14
09:56:15
09:56:16
09:56:17
09:56:19
09:56:20
09:56:21
09:56:22
09:56:23
09:56:24
09:56:25
09:56:26
09:56:27
09:56:28
as you can see this dramitically increases page load time (this is for older women, they will think the world ended if it doesn't load in 5 seconds and keep clicking )
The first page, which loads the include very fast start out like this (checkRooms.php is the include in question)
<?php session_start(); session_destroy(); session_start(); include('db.php'); require('checkRooms.php'); ?>
the second page is VERY simalir:
<?php session_start(); include('checkRooms.php'); ?>
why would this code load sooooooooo slow on only this page? this makes no sense to me. the worst part is everything loaded nice and fast until this morning
-
It's best to use a switch, because of security issues.
<?php switch($_REQUEST['page']){ case "home": include('homepage.html'); break; case "products": include('products.html'); break; default: include('homepage.html'); break; } ?>
-
I am setting up a registration form for a trip.
The variable name is the location name
the key is the number of people who can fit in a room at that location
the value is the number of rooms available that will fit that many people.
I want to scan the DB for the number of people registered for that location, with there number of roommates, and see if any rooms are still available.
Here is my script, but I feel like it can be done in a better way. Any input is appreciated.
<?php // NUMBERS $foxridge[8] = 3; $foxridge[6] = 6; $alpine[8] = 10; $alpine[6] = 10; $valley[8] = 5; $valley[6] = 1; $wildflower[2] = 23; $wildflower[4] = 32; $wildflower[6] = 20; $snowpine[2] = 4; $snowpine[4] = 18; $snowpine[6] = 30; $snowpine[8] = 15; foreach($foxridge as $k=>$v){ $sql = "SELECT * FROM breakaway WHERE b_location='foxridge' AND b_numRoommates='".$k."'"; if(mysql_num_rows(mysql_query($sql)) >= $v) $foxridge[$k] = false; } foreach($alpine as $k=>$v){ $sql = "SELECT * FROM breakaway WHERE b_location='alpinemeadow' AND b_numRoommates='".$k."'"; if(mysql_num_rows(mysql_query($sql)) >= $v) $alpine[$k] = false; } foreach($valley as $k=>$v){ $sql = "SELECT * FROM breakaway WHERE b_location='valleyvillage' AND b_numRoommates='".$k."'"; if(mysql_num_rows(mysql_query($sql)) >= $v) $valley[$k] = false; } foreach($wildflower as $k=>$v){ $sql = "SELECT * FROM breakaway WHERE b_location='wildflower' AND b_numRoommates='".$k."'"; if(mysql_num_rows(mysql_query($sql)) >= $v) $wildflower[$k] = false; } foreach($snowpine as $k=>$v){ $sql = "SELECT * FROM breakaway WHERE b_location='snowpine' AND b_numRoommates='".$k."'"; if(mysql_num_rows(mysql_query($sql)) >= $v) $snowpine[$k] = false; } ?>
-
<?php $month_str = date("M",strtotime($date_from_db)); $month_int = date("m",strtotime($date_from_db)); $day = date("d",strtotime($date_from_db)); ?>
-
just remember, "logged in" is just a variable.
everything is a variable if you have to question it.
one major point that I think about every day when scripting PHP is NEVER ASSUME.
-
I give you both the right to eSlap me. it's been a long day....
thank you.
-
here's what I got:
<?php function getNumRows($qry){ if($qry <> NULL){ $qry = "SELECT * FROM epostcard WHERE ".$qry; } else { $qry = "SELECT * FROM epostcard"; } $result = mysql_query($qry); $numRows = mysql_num_rows($result); unset($qry,$result); return $numRows; } $totalPostcards = getNumRows("p_pcSentDate <= '". $dateStart . "' AND p_pcSentDate >= '" . $dateEnd . "'");
this returns 0 rows. (incorrect)
$totalPostcards = getNumRows("p_pcSentDate BETWEEN '". $dateStart . "' AND '" . $dateEnd . "'");
this returns the correct rows, however I need to get the rows that are on dateStart and dateEnd - this does the rows BETWEEN (obv),
-
I am wondering how I would make a <select> box in php, that goes from June 30th 2009 (5/30/09) to (dynamic date) and shows only TUESDAYS.
it should be formatted like so:
<option value="2009/05/30">June 30th, 2009</option>
Thanks!
-
correct...the extract() function removes it
soo
you have "user_id" in a table
$row = mysql_fetch_array($result)
$row['user_id'];
extract($row);
$user_id
got it?
-
I have some data I want to query between dates. In the MySql database, they have a datetime field (Y-m-d h:i:s)
How can I effectivily query a range of date
like: SELECT * FROM table WHERE tb_date < "2009-01-01" AND tb_date > "2009-06-01"
-
menu link would be the column name, btw.
and you will need to format the link inside of it.
-
<ul> <?php $sql = "SELECT * FROM table"; $result = mysql_query($sql); while($row = mysql_query($result)){ extract($row); echo "<li>".$menu_link."</li>"; } ?> </ul>
-
Pmpl, rofl wtf ??? Is this.
dreamweaver meets syntax errors.
Using GD to merge two images (like a watermark)
in PHP Coding Help
Posted
I am trying to merge two images... the background image will have an overlay that is basically a border around the image...
Here is my code, but it's only outputting the background image and not the overlay.