Prismatic
-
Posts
503 -
Joined
-
Last visited
Posts posted by Prismatic
-
-
you'd hafta learn regular expressions lol.. writing it for you would be of little beneficial for you, uhm, try exploding by new lines, thats another way..
explode("\n",$theQuestionsAndAnswersAndAllDatWhiteSpace);
den loop thru dat and check for data in da array elements.. if it has data throw it into an array.. every 5 elements start a new array..
If you ever were to buy a script, don't buy it from someone who can't even muster up the integrity to spell the English language correctly. It would reflect in the finished product, trust me.
"Dat's all, folks!"
-
You can if you want.
You can use any text editor to write PHP.
Simply place that code inside an empty file, save it as "info.php", upload it to your websever and visit the file.
-
<?php echo date("M dS, Y", strtotime(row['date'])); ?>
or, when you run the query just do
SELECT *, UNIX_TIMESTAMP(date) AS date .....
OR just do this and be done with it completely,
SELECT *, DATE_FORMAT(date, '%b %D, %Y') AS date .... <?php echo $row['date'] ?>
-
Here's a really terrible way to generate a CSV and dump it to the browser
<?php error_reporting(E_NONE); /** Connection stuff... * * * */ /** Your table here */ $table = ""; $query = mysql_query("SELECT * FROM {$table} LIMIT 1"); foreach(mysql_fetch_assoc($query) as $key => $val) $csv_col[] = '"'. $key .'"'; $cols = implode(", ", $csv_col) ."\n"; $query = mysql_query("SELECT * FROM {$table}"); while($row = mysql_fetch_row($query)) { foreach($row as $val) { $csv_row[] = '"'. trim($val) .'"'; } $rows .= implode(", ", $csv_row) ."\n"; $csv_row = array(); } print_r($cols.$rows); ?>
-
Solved.
<?php function array_insert(&$array, $value, $offset) { if (is_array($array)) { $array = array_values($array); $offset = intval($offset); if ($offset < 0 || $offset >= count($array)) { array_push($array, $value); } elseif ($offset == 0) { array_unshift($array, $value); } else { $temp = array_slice($array, 0, $offset); array_push($temp, $value); $array = array_slice($array, $offset); $array = array_merge($temp, $array); } } else { $array = array($value); } return count($array); } ?>
-
down?
Say I've got an array
Array ( [1] => url1 [2] => url2 [3] => url3 [4] => url4 )
How would I go about making a function that would allow me to insert a new element in spot 2, and have all others move down accordingly so I end up with this?
Array ( [1] => url1 [2] => sub_url1 [3] => url2 [4] => url3 [5] => url4 )
-
<?php $t1 = strtotime('4/2/2009 16:17'); $t2 = strtotime('4/27/2009 14:29'); $delta_T = ($t2 - $t1); $days = round(($delta_T % 604800) / 86400, 2); $hours = round((($delta_T % 604800) % 86400) / 3600, 2); $minutes = round(((($delta_T % 604800) % 86400) % 3600) / 60, 2); $seconds = round((((($delta_T % 604800) % 86400) % 3600) % 60), 2); ?>
One way.
-
<?php // Our name $name = "john Doe"; // Seperate the name at the space, this will // give us an array with 2 values $parts = explode($name); // ucfirst makes the first character uppercase echo ucfirst($parts[0]); ?>
-
Without knowing your table structure, this should work.
<select class="input" name="project" > <option value=""><?=$row->project?></option> <?php $ara = "SELECT * FROM listings ORDER BY project" ; $cak = mysql_query($ara); while ($don = mysql_fetch_array($cak)) { if($don['project']) echo "<option value=\"". $don['project'] ."\"> ". $don['project'] ."</option>"; } ?> </select>
Also this
<select class="input" name="project" > <option value=""><?=$row->project?></option> <?php $ara = "SELECT * FROM listings WHERE project != "" ORDER BY project" ; $cak = mysql_query($ara); while ($don = mysql_fetch_array($cak)) { echo "<option value=\"". $don['project'] ."\"> ". $don['project'] ."</option>"; } ?> </select>
-
use regular HTML for the page, add <?php ?> tags whenever you wish to invoke php, and save the file as a .php
-
Try this
<?php echo "<img src='http://www.website/uploaded_files/". $info['photo'] ."'". imageResize($resized[0], $resized[1], 150) ."> <br>"; ?>
-
<?php $resized= getimagesize("uploaded_files/". $info['photo']); ?>
-
<?php // Get the ID from the URL, e.g, mypage.php?id=126 $id = (int)$_GET['id']; // Query the database for the row with that ID $query = mysql_query("SELECT * FROM my_table WHERE id = '{$id}' LIMIT 1"); // Get the data $data = mysql_fetch_array($query); // Now you have all the data for that one row die(print_r($data)); ?>
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"> <head> <title>Energy Saving › Admin Log In</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel='stylesheet' href='login.css' type='text/css' media='all' /> </head> <div class="container"> <div id="header"></div> <body class="login"> <div id="login"> <h1><a href="login.html">Energy Saving Logo</a></h1> <?php $loginname = "admin"; $loginpassword = "password"; if ($_POST['text'] != $loginname || $_POST['password'] != $loginpassword) { ?> <div id="login_error"> <strong>ERROR</strong>: Incorrect Username or Password.<br /></div> <?php } else { ?> <div id="login_sucess"> <strong>LOGIN SUCCESSFUL</strong><!-- : <a href="login.html">Click here</a> to continue.--> <?php include("login.html"); ?> </div> <?php } ?> <form name="login" id="loginform" action="login.php" method="post"> <p> <label>Username:<br /> <input type="text" name="text" id="user_login" class="input" value="" size="20" tabindex="10" /></label> </p> <p> <label>Password:<br /> <input type="password" name="password" id="user_pass" class="input" value="" size="20" tabindex="20" /></label> </p> <p class="submit"> <input type="submit" name="submit" id="submit" value="Log In" tabindex="100" /> </p> </form> </div> </body> </html>
-
the document path comes from the factory with a trailing slash, change your require line to this
require($_SERVER["DOCUMENT_ROOT"] ."config/db_config.php");
-
put the config data into a file and name it something like 'config.inc', then just add the line at the top of each page: include('config.inc'). there you go.
As a side note, never do this. Unless specifically configured to, your webserver will process the .inc file as plain text and send it to the browser, allowing anyone to view your database connection info. It's an easy and stupid way to find yourself "hacked" (I use the term loosely)
-
<?php /** Initial sums */ $sum_1 = rand(3, 18); $sum_2 = rand(1, 6); $sum_3 = $sum_2 + $sum_1; echo ($sum_1 >= 16 ? ($sum_2 = 6 ? $sum_3 + rand(1, 6) : $sum_3) : ""); ?>
-
<?php // Our simulated text area. Note the newlines. $data = "http://www.google.com\n http://www.yahoo.com\n http://www.ask.com\n http://www.aol.com"; // Seperate each line at it's newline character $lines = explode("\n", $data); // Show each one as a link foreach($lines as $line) { echo "<a href=\"{$line}\">{$line}</a></br>"; } ?>
-
<?php $sql = "some code"; if(mysql_query($sql)) { echo "Successful<br/>"; sleep(6); //6 seconds header("Location: newPage.php"); } else { echo "Unsuccessful"; sleep(6); //6 seconds header("Location: newPage.php"); } ?>
Will not work. Output has been sent to the browser Alternatively he could use a META tag instead of Javascript, but yea.
Doh, good catch.
-
Hi,
How can I jump (redirect) to another page after say 6 seconds from inside PHP code. For example, I wish to say:
$sql = "some code";
if(mysql_query($sql))
{ echo "Successful<br/>";
//redirect to page A after 6 seconds
}
else
{ echo "Unsuccessful";
//redirect to page B after 6 seconds
}
The only way I know how to redirect to another page after some time is using javascript.
<script type="text/javascript">
function timedMsg()
{ var t = setTimeout("location.href='file.html'",6000);
}
</script>
But how can I write javascript inside PHP code? I would be very grateful for all help.
<?php $sql = "some code"; if(mysql_query($sql)) { echo "Successful<br/>"; sleep(6); //6 seconds header("Location: newPage.php"); } else { echo "Unsuccessful"; sleep(6); //6 seconds header("Location: newPage.php"); } ?>
-
awesome.. i figured it was a function like explode.. ive used that before but wasnt sure how to work the code.. So i should just put that on for the else and make an array of the bad codes?
any chance you know how to modify and add java verification to vbulletin userfields huh?
<?php require('includes/db.php'); $sql = "SELECT userid, field5 FROM userfield"; $result = mysql_query($sql); while ($myrow = mysql_fetch_array($result)) { $userid = $myrow['userid']; $field5 = $myrow['field5']; $i = 0; $e = 0; if(eregi('^[0-9]{3}-[0-9]{3}-[0-9]{3}$', $field5)) { $e = ($e + 1); } else { $new_tag = implode("-", str_split(preg_replace('/[^\d]/', "", $field5), 3)); $update = "UPDATE userfield SET field5='{$new_tag}' WHERE userid='{$userid}'"; $i = ($i + 1); } } $total = ($e + $i); echo $total, ' NEW RECORDS TODAY!<br />'; echo $e, 'USERS NOT CHANGED<br />'; echo 'SUCCESSFULLY UPDATED ',$i,' USERS RECORDS'; ?>
-
With PHP alone? No. With PHP at all? Nope!
Unless you have a mobile card on your laptop/PC and a cell provider, you'll need to write an app for your phone that automatically publishes your SMS's to a remote DB.
OR find a way to automatically push SMS's from your phone to an email account of your choice, then routinely poll that email account for new messages and add them to the DB.
-
A much better way howeverwould be to use the prebuilt variable.
<?php echo $_SERVER['REQUEST_TIME']; ?>
Never trust $_SERVER.
-
<?php echo time(); ?>
This will output a unix timestamp of the current time, you can format it with date()
Parsing a document into a particular format.
in PHP Coding Help
Posted
I'm sure your intentions are pure, but you have to understand it's actually harder to read when you talk like that.