wildteen88
Staff Alumni-
Posts
10,480 -
Joined
-
Last visited
Never
Everything posted by wildteen88
-
Code runs fine when you use echo and not die.
-
What do you mean by wrapper? post your current code here.
-
$word = 'house'; $newWord = ''; for($i = 0; $i <= strlen($word); $i++) { $newWord .= $word{$i}.'*'; } echo $newWord;
-
Get what from MySQL? To get data from a MySQL table just use a standard SELECT Query // send a query to MySQL $sql = 'SELECT * FROM your_table'; $result = mysql_query($sql); // get results while($row = mysql_fetch_assoc($result)) { echo '<pre>'.print_r($row, true).'</pre>'; }
-
mysql_query only returns a result resource. In order to get the data from the result resource you'll need to use one of the mysql_fetch_(assoc, array oe row) functions, eg // Define variables $result = mysql_query("SELECT log_filename, log_issue, log_month FROM uploads_log"); while($row = mysql_fetch_row($result)) { list($filename, $issueno, $issuemonth) = $row; print "<a href=www.url/uploads/$filename><?php echo Issue $issueno.", ".$issuemonth; ?></a>"; }
-
The year for mktime is limited to 1970 - 2038
-
[SOLVED] Basic CSS: Body Margins (stuck with a 1px margin somehow)
wildteen88 replied to webmaster1's topic in CSS Help
Could you also provide your HTML too. -
[SOLVED] Basic CSS: Body Margins (stuck with a 1px margin somehow)
wildteen88 replied to webmaster1's topic in CSS Help
Can we see this gap you are getting? Also what browser are you using to test your CSS/HTML, does the gap appear in all browsers* or certain ones? * Make sure you test your CSS/HTML in more than one browser, eg IE (6 and 7) FF, Opera, Safari etc. -
This line $name[$i] = array(getResultById("data_set", $i)); Should be $name[$i] = getResultById("data_set", $i);
-
[SOLVED] mysql_fetch_row or mysql_fetch_assoc or mysql_fetch_array?
wildteen88 replied to limitphp's topic in PHP Coding Help
In order to for you to know which to use you'll need to know what each of the above returns. mysql_fetch_assoc - returns an associative array of your field names eg $row['field_name_here'] mysql_fetch_row - returns a numeric array eg $row[0] returns the first column, $row[1] returns the second column etc. However mysql_fetch_array retuns both an associative and numeric array. I personally use mysql_fetch_assoc. -
Looking at the code a loop would be much better in this case. <?php // list available departments $keys = array('EELEAD', 'MELEAD', 'OELEAD', 'SWLEAD', 'SELEAD', 'ST'); // loop through the departments foreach($keys as $key) { // check to see if the department ($key) is within the $_SESSION and is set to NEW if(isset($_SESSION[$key]) && strtoupper($_SESSION[$key]) == 'NEW') { // work out the prefix from the key to access the fields within the $_SESSION $pfx = substr($key, 0, 2); // setup the query $query = "INSERT INTO Personel(EMPID, FName, LName, Email, Phone, Department, Picture) ". "VALUES ( '".$_SESSION[ $pfx.'EMPID' ]."', '".$_SESSION[ $pfx.'FNAME' ]."', '".$_SESSION[ $pfx.'LName' ]."', '".$_SESSION[ $pfx.'Email' ]."', '".$_SESSION[ $pfx.'Phone' ]."', '$pfx', '<img src='".$_SESSION[ $pfx.'EMPID' ]."?size=small' width=150/>')"; // run the query, and error will display if there is a problem mysql_query($query) or die('MySQL Error: '.mysql_error() . '<br />Query: <pre>'.$query.'</pre>'); } } ?> Do note that the code above is untested.
-
If you are developing your PHP script locally which uses a MySQL database. Then you'll need to backu[ your database on your local server and then import your database to your remote MySQL server. You do not access the files stored in C:\xampp\mysql\data. You'll have to either use the Command Line or use something like phpMyAdmin (this is easiest) to perform your backup.
-
Try updating your DVD/CD Drives Firmware. I've had a similar issue you're describing in the past this solved it for me.
-
White spaces on head of document after include or require a file
wildteen88 replied to giba's topic in PHP Coding Help
It could be do with how you are saving your PHP files regarding the charset. Ensure you're saving your files as ASCII. Or if you're saving them as UFT-8 then save them as UTF-8 without BOM. -
I have only merged your two queries together. As before only the last query was being run: $query = "SELECT village, SUM(health) FROM users GROUP BY village"; The first query: $query = "SELECT village, SUM(skill) FROM users GROUP BY village"; Is not being run at all, as the last query above is overriding it. This is why I have merged your two queries.
-
Here: $query = "SELECT village, SUM(skill) FROM users GROUP BY village"; $query = "SELECT village, SUM(health) FROM users GROUP BY village"; $result = mysql_query($query) or die(mysql_error()); Only your last query will be run. Your query should be $query = "SELECT village, SUM(skill), SUM(health) FROM users GROUP BY village"; $result = mysql_query($query) or die(mysql_error());
-
To see why your query failed use mysql_error after this line: echo "An error occured during insert!<br/>"; However looking at you code, it could be failing because you're using a MySQL reserved word within your query which is desc. But until we see the true error we cant suggest a fix.
-
The links are working fine for me. However it loads the same content no mater what category you choose.
-
EDIT: Nevermind beaten to it Its a JavaScript error. It should be: echo "<div id=\"category\" onclick=\"location.href='default.php?catid".$cats['cat_id']."';\">; Alternatively your should remove the onClick even entirely and wrap the contents of the div within an anchor tag, eg echo "<div id=\"category\"><a href=\"default.php?catid".$cats['cat_id'].|"\">DIV CONTENT HERE</a></div>";
-
Actually all five are being displayed. It's your HTML that is causing the problem. The following highlighted code should be outside of your while loop: Fixed code: <div id=\"navbar\"> Select A Category </div> <div id=\"items\">"; $get_cats = mysql_query("SELECT * FROM tbl_category"); while($cats = mysql_fetch_array($get_cats)) { echo "<div id=\"category\" onclick=\"location.href=default.php?catid".$cats['cat_id'].";\"><b>".$cats['cat_name']."</b><br> <small>".$cats['cat_description']."</small></div>\n"; } echo "</div></div></body></html>";
-
The error message are pretty straight forward. Apache and MySQL have failed to start as the port 80/3306 are both being used. Port 80 is used by Apache Port 3306 is used by MySQL. Before starting Apache/MYSQL via XAMPP make sure nothing is running on port 80 or port 3306. Ports can only be used by one process at a time. If you're trying to connect to your local MySQL installation, then you'll need to use localhost instead of mysql2.namesco.net as the hostname -- this will be defined in your PHP script (I presume dbc.php)
-
Installation problems..."a script cannot run"
wildteen88 replied to benjipie's topic in PHP Installation and Configuration
Do not use the PHP installer. Just download the PHP zip package from php.net instead. Extract the contents of the zip to C:/php and PHP is installed. Now install Apache if you havn't done so. After Apache is installed you'll need to configure Apache to use PHP. To do this open up Apaches configuration file (httpd.conf) and add the following lines at the bottom LoadModule php5_module "C:/php/php5apache2_2.dll" PHPIniDir "C:/php" AddType application/x-httpd-php .php Save the httpd.conf and restart Apache. You also want to: Add PHP to the Windows Path Environment Rename php.ini-recommended within C:/php to just php.ini -
The time is inherited from the computer Apache is installed on. I don't think you can modify the date within Apache's configuration
-
Requesting a file using the HTTP wrapper will not return the PHP source code but the output of the script. Your code will not work.
-
You are missing a ; at the end of this line: echo file_get_contents('../news.hza')