Prismatic
Members-
Posts
503 -
Joined
-
Last visited
Everything posted by Prismatic
-
Need to reformat the information in a column of a mysql table.
Prismatic replied to danieliser's topic in PHP Coding Help
<?php $bad_tags = array("123123123", "123~123123", "123 123 123", "abc123-123~123hgt"); foreach($bad_tags as $tag) { echo implode("-", str_split(preg_replace('/[^\d]/', "", $tag), 3)) ."\n"; } ?> Output: 123-123-123 123-123-123 123-123-123 123-123-123 -
ImageTTFText has an angle option. -90 should draw it vertically. However, if you're looking to draw the letters upright but vertical like this h e l l o Then you'll need to take your string, explode it into indivual characters, then loop over each character placing it on the picture xx pixels lower then the previous letter
-
View the source of the generated page. What is the src="" value for the image?
-
Try this, it's untested. <?php $result = mysql_query("SELECT * FROM products"); $count = mysql_num_rows($result); if($count < 17) { $page = '<a href = "products.php">Page 1</a>'; } elseif($count < 37) { $page .= '<a href = "products.php?page=1">Page 1</a>' . " "; $page .= '<a href = "products.php?page=2">Page 2</a>'; } $totalproducts = mysql_num_rows($result); echo $page; echo '<table width="750" border="0" align="center">'; echo '<tr>'; $i = 0; while($row = mysql_fetch_array($result)) { if( (($i % 4) == 0) && ($i != 0) ) { echo '</tr><tr>'; } /** * I'm assuming all your image's reside in the /img directory. */ echo '<td width="25%" height="150" align="center">' . '<img src="img/' . substr($row['prod_img'], strrpos("/", $row['prod_img']) + 1, strlen($row['prod_img'])) . '"/>' . '<br>' . $row['prod_name'] . '<br>' . '$' . $row['prod_price'] . '</td>'; $i++; } echo '</tr>'; echo '<table>'; ?>
-
<?php $file = "path_to_file.jpg"; header('Content-type: image/jpeg'); readfile($file); exit; ?>
-
We won't give you the full script. You need to make an attempt or you'll never learn. How much of your system is done sofar? And how is your database structured?
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN"> <html> <head> <title></title> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> First name: <input type="text" name="first_name"><br> Last name: <input type="text" name="last_name" style="position: relative; left: 1px;"> <input type="submit" value="Submit"> </form> <?php $first = $_POST['first_name']; $last = $_POST['last_name']; $charecter = array("is gay", "is cool", "is a funny", "is a wierdo", "is just dumb"); $doing = array("farts alot", "runs in circles", "...", "and loves strawberry shortcake"); $number = range('0','9'); $test = ($number[rand(0,9)]) . ($number[rand(0,9)]); if($_POST['submit']) { if(!empty($first) && ($last)) { echo $first . " " . $last . " " . $charecter[rand(0,4)] . " and " . $doing[rand(0,3)] . "<br /> Lucky Number: " . $test . "."; } if($test < 99 && $test > 50) { echo "That is a great number!"; } } ?>
-
Another SQL injection question / check my function
Prismatic replied to mo's topic in PHP Coding Help
It also won't work. You only set $input to $output if magic quotes is on. If it's not, mysql_real_escape_string ends up escaping an empty $output variable. -
Send Text Messages To Phones Using PHP?
Prismatic replied to Punk Rock Geek's topic in PHP Coding Help
Not needed... Most providers allow you to simply email a phone an SMS, go here for a list http://www.makeuseof.com/tag/email-to-sms/ -
Are you using short tags?
-
I had the same problem years ago and discovered an Apache setting that would include a file across any site you wanted... Unfortunately I cant find the trick anymore
-
No, playlists will not be filenames. They are just going to be in stored in the database. So, when you mysql_real_escape_string() a value, it converts all single quotes into \' Does the \, get stored in the database like that? With the backslash? Yes. When you recall the data from the database run stripslashes() on it to remove them.
-
str_replace("_", " ", $string);
-
str_replace(" ", "_", $string);
-
edit - dangit premiso :|
-
[SOLVED] How would you trim excess spaces inside a string?
Prismatic replied to limitphp's topic in PHP Coding Help
No, that removes all spaces. use this <? $string = "this has lots of extra spaces"; echo preg_replace('/\\s{2,}/',' ',$string); ?> -
me so slow
-
Smarty is not hard at all. You put all your templates in the templates folder. inside each template where you want a variable to show do {$variable_name} then you simply do $smarty = new Smarty(); $smarty->assign("variable_name", "Hello world!"); $smarty->display("template_file.html"); It can be more complicated if you'd like but all template engines will follow the same general flow.
-
<?php $s_date = strtotime("2009-03-01 12:00"); $e_date = strtotime("2009-03-03 14:00"); $date = strtotime("2009-03-02 13:00"); if($date > $s_date && $date < $e_date) { print "Date is between start and end"; } else { print "Date is outside start and end"; } ?>
-
<?php $data = array(array("name" => "laptop 1", "username" => "user 1", "start" => "2009-01-31 10:00", "end" => "2009-01-31 12:00"), array("name" => "laptop 1", "username" => "user 1", "start" => "2009-02-01 10:00", "end" => "2009-02-03 12:00"), array("name" => "laptop 1", "username" => "user 1", "start" => "2009-03-01 10:00", "end" => "2009-03-03 12:00"), array("name" => "laptop 1", "username" => "user 1", "start" => "2009-04-01 10:00", "end" => "2009-04-03 12:00"), array("name" => "laptop 1", "username" => "user 1", "start" => "2009-05-01 10:00", "end" => "2009-05-03 12:00")); foreach($data as $key => $val) print $val["start"] ."<br />"; ?> Returns: 2009-01-31 10:00 2009-02-01 10:00 2009-03-01 10:00 2009-04-01 10:00 2009-05-01 10:00 edit - im slow
-
[SOLVED] Do I have to do PHP for this?
Prismatic replied to The Little Guy's topic in PHP Coding Help
Did you try it? -
You can, just make sure it gets inserted into the <head></head> of your document
-
please help me on making my own basic email server.
Prismatic replied to edrew04's topic in PHP Coding Help
You sir, have no idea what you're talking about... And frankly I'm not sure if I can say what you actually want. Do you need to create a guestbook using MS Access as a database? Yes, I need to create a guestbook using MS Access as a database... Why do you keep quoting people and not adding anything? Is that your way of bumping? If so, you're not going to get a better answer. Sorry. There isn't a *magic* answer. he keeps adding his replies inside the quotes. -
For the value of each element you wish to repopulate assign a php variable to it <input type="text" name="something" value="$something_value"> Then in your script you would simply do $something_value = $_POST['something']; //Other code... //Code to display the form(s)