Jump to content

jcbones

Staff Alumni
  • Posts

    2,653
  • Joined

  • Last visited

  • Days Won

    8

Everything posted by jcbones

  1. See what this gives you. <?php include"scripts/connect.php" ; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM movies WHERE type LIKE 'movie' ORDER BY title"; $result = mysql_query($query) or trigger_error($query . ' has encountered an error: <br />' . mysql_error()); $num = mysql_num_rows($result) $half_rows = floor($num / 2); $i = 0; if($num > 0) { echo '<div style="float:left">'; while($row = mysql_fetch_assoc($result)) { echo $result['title'] . '<br/>'; if(++$i == $half_rows) { echo '</div><div>'; } } echo '</div>'; } ?>
  2. I think you are on to something. There are 3 different php.ini. Here is a very good tutorial for installing on a windoz machine.
  3. Is event_date a DATE, TIMESTAMP, or DATETIME column?
  4. You do know you can save in a .xml file right? If you just want the data output for another program to use, you could just set the header to recognize the .php file as a .xml file. header('Content-type: text/xml');
  5. You're welcome! Glad I finally explained something clearly.
  6. foreach ($results as $result) { $page = $result['page']; $total = $result['SUM(`like`)']; $extremoved = substr($page, 0, -4); foreach ($pages as $key => $value) //slight change to the foreach, this will grab the key and the value. { if (ucwords($extremoved) == $value) // I need $name to equal the value of the array... $name = 'about' NOT ITS KEY => 'About', According to your block below, 'About' is the value and not the key. { ?> <div class="mhl mvs"> <span class="left"><?php echo ucwords($key); ?></span> // I need this to echo out the $names KEY rather than $extremoved <span class="f_right">(<?php echo $total; ?>)</span> </div> <?php } } } $pages = array( 'KEY' => 'VALUE', 'about' => 'About', 'accountSettings' => 'Account Settings', );
  7. I noted the changes, and additions. Hope it helps. <?php require_once('Connections/connector.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_connector, $connector); $query_Recordset1 = "SELECT name FROM listings_name ORDER BY name_id ASC"; $Recordset1 = mysql_query($query_Recordset1, $connector) or die(mysql_error()); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Name Search</title> <style type="text/css"> </style> <link href="common_styles.css" rel="stylesheet" type="text/css" /> <link href="main_cols.css" rel="stylesheet" type="text/css" /> <script src="SpryAssets/SpryData.js" type="text/javascript"></script> <script src="SpryAssets/SpryHTMLDataSet.js" type="text/javascript"></script> <script type="text/javascript"> var ds1 = new Spry.Data.HTMLDataSet(null, "listings_name", {firstRowAsHeaders: false, columnNames: ['name']}); ds1.setColumnType("name", "html"); </script> </head> <body> <div id="wrapper"> <table width="998" border="0" cellspacing="4" id="listings_name"> <?php //changed this section to break the while loop, when half the rows have been displayed. $half_rows = round($totalRows_Recordset1 / 2); $i = 0; while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) { ?> <tr> <td><?php echo $row_Recordset1['name']; ?></td> </tr> <?php if(++$i == $half_rows) break; } ?> </table> <?php //This table added, Holds 2nd half of names. I'm sure you can get it to line up right in dreamweaver. ?> <table width="998" border="0" cellspacing="4" id="listings_name"> <?php while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) { ?> <tr> <td><?php echo $row_Recordset1['name']; ?></td> </tr> <?php } ?> </table> </div> <div id="spryTable" spry:region="ds1"> <table align="center"> <tr> <th spry:sort="name"> </th> </tr> <tr spry:repeat="ds1" spry:setrow="ds1" spry:hover="hover" spry:select="selected"> <td height="40" align="center">{name}</td> <td height="40" align="center">{name}</td> </tr> </table> </div> </body> </html>
  8. What server are you running? You may have to download the mysql.dll, or possibly just move it to another folder. I think you just have to move php_mysql.dll from the main PHP folder to the /ext folder. Take note of the commented php.ini below. ;;;;;;;;;;;;;;;;;;;;;; ; Dynamic Extensions ; ;;;;;;;;;;;;;;;;;;;;;; ; If you wish to have an extension loaded automatically, use the following ; syntax: ; ; extension=modulename.extension ; ; For example, on Windows: ; ; extension=msql.dll //<-DO NOT DO IT HERE-> ; ; ... or under UNIX: ; ; extension=msql.so ; ; ... or with a path: ; ; extension=/path/to/extension/msql.so ; ; If you only provide the name of the extension, PHP will look for it in its ; default extension directory. ; ; Windows Extensions ; Note that ODBC support is built in, so no dll is needed for it. ; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5) ; extension folders as well as the separate PECL DLL download (PHP 5). ; Be sure to appropriately set the extension_dir directive. ; ;extension=php_bz2.dll ;extension=php_curl.dll ;extension=php_dba.dll ;extension=php_exif.dll ;extension=php_fileinfo.dll extension=php_gd2.dll ;extension=php_gettext.dll ;extension=php_gmp.dll ;extension=php_intl.dll ;extension=php_imap.dll ;extension=php_interbase.dll ;extension=php_ldap.dll extension=php_mbstring.dll ;extension=php_ming.dll ;extension=php_mssql.dll extension=php_mysql.dll //<-DO IT HERE-> NOTICE A DIFFERENCE IN THE NAME. extension=php_mysqli.dll ;extension=php_oci8.dll ; Use with Oracle 10gR2 Instant Client ;extension=php_oci8_11g.dll ; Use with Oracle 11g Instant Client ;extension=php_openssl.dll ;extension=php_pdo_firebird.dll ;extension=php_pdo_mssql.dll extension=php_pdo_mysql.dll ;extension=php_pdo_oci.dll ;extension=php_pdo_odbc.dll ;extension=php_pdo_pgsql.dll extension=php_pdo_sqlite.dll ;extension=php_pgsql.dll ;extension=php_phar.dll ;extension=php_pspell.dll ;extension=php_shmop.dll ;extension=php_snmp.dll ;extension=php_soap.dll ;extension=php_sockets.dll ;extension=php_sqlite.dll ;extension=php_sqlite3.dll ;extension=php_sybase_ct.dll ;extension=php_tidy.dll ;extension=php_xmlrpc.dll ;extension=php_xsl.dll ;extension=php_zip.dll
  9. This is why.
  10. I'm not real good at explanations, but I'll try to be clear. $a = array(); //define $a as an empty array. while ($x = mysql_fetch_array($query_name,MYSQL_NUM)) //mysql_fetch_array will return false after the resource handle has run out, so when the query is empty, $x = false which breaks the while loop. { $a[] = $x[0]; //if $x is passed to the while loop, it will contain an array full of row data. Currently you are asking it to only pass the first value to the $a array. //You then append this data to the $a array ([] denotes an array.) } echo ($a[0]); //you only echo the first value from the $a array. Arrays explained better than I ever could
  11. You have a quite a bit of HTML errors in there. You are putting table rows inside of a division. If you wish to use table rows, you must make a table first. You are also creating line items without a list of the ordered or un-ordered type. As far as the PHP goes, you need to ORDER BY tblnews.Category, then check the category against the last one pulled, if it is the same, display it, otherwise start a new box.
  12. After the while loop, $x = false; So, it will not echo anything. while(this.condition.equals.true)
  13. Well you don't have to strip anything, just echo it. echo $types[0] . ' , ' . $types[3];
  14. I don't understand your question? It is NOT adding an extra key, all keys have a value. Try wrapping the print_r() function in <pre> tags. echo '<pre>'; print_r($types); echo '</pre>'; You will find you have a multi-dim. array, just like you ask PHP to build for you. If you don't want it multi-dim. then, $types = array(); while ($row = mysql_fetch_array($query_name,MYSQL_NUM)) { $types[] = $row[0]; } echo '<pre>'; print_r($types); echo '</pre>';
  15. This is a HTML problem. If you look at your source code, you would see that your links are there, but you didn't close the <li> tags, nor did you close your " quotes in the <a> tag. Therefore it is seeing most of your code as a url in the links. Here is the section you are having a problem with, as it outputs on my server. This section adds the link perfectly fine <li><a href="http://www.google.com> View Personalised Protection Content</a><BR> <HR> This link add fine, however when i add the resolving if statement. This link disappear here and the Resolving section just doesnt appear <li><a href="http://www.google.com> View Personalised Detection Content</a><li><a href="http://www.google.com> View Personalised Resolving Content</a>
  16. Yes, each $row is already an array, then you are making another array holding all of the rows.
  17. That is not what he is asking Dodd, he want's to separate the columns, 50% in one, and 50% in the second.
  18. Instead of writing the code to the database, write it to a file. Save the file as PHP and then include it into your other scripts. <?php if($_POST['from_site']) { unset($_POST['from_site']); $out_data="<?php \$db_name='{$_POST['db_name_in']}'; \$table_prefix='{$_POST['table_prefix_in']}'; \$host='{$_POST['host_in']}'; \$user='{$_POST['user_in']}'; \$password='{$_POST['password_in']}'; ?>"; $fp = fopen("./config.php", "w"); fwrite ($fp, $out_data); fclose ($fp); } ?> <form action="" method="post"> <label for="host_in">Database Host:</label><input type="text" name="host_in" value="localhost" /><br /> <label for="db_name_in">Database Name:</label><input type="text" name="db_name_in" /><br /> <label for="table_prefix_in">Table Prefix:</label><input type="text" name="table_prefix_in" /><br /> <label for="user_in">User</label><input type="text" name="user_in" /><br /> <label for="password_in">Password</label><input type="password" name="password_in" /><br /> <br /> <input type="submit" name="from_site" value="Submit" /> </form> Of course, you would need to save this to a directory that is above your public HTML, or is restricted from public view (.htaccess). The reason this is the only viable alternative is that you cannot access a database without the database name, host, user, and password. Therefore, logic states that you cannot retrieve these values from beyond that point.
  19. None of that is PHP, please post your code. No one will steal it, I promise.
  20. $cars[0]="Saab"; $cars[1]="Volvo"; $cars[2]="BMW"; $cars[3]="Toyota"; foreach ($cars as $key => $value) { $cars[$key] = "TEST"; //change the value. echo $key . " " . $value . "<br />"; //this will still output Saab, BMW, Toyota, etc. Because the value of "$value" has already been set, before we alter it. } echo '<pre>'; print_r($cars); echo '</pre>';//this should print an array full of "TEST". AND for ($i=0; $i < count($cars); $i++) { echo $cars[$i]; //this should print your array Saab, BMW, Toyota, etc. $cars[$i] = 2; //we now change the value of the array to 2. } echo '<pre>'; print_r($cars); echo '</pre>';//should show that cars is an array full of 2's. That should clear it up. Let us know.
  21. Do you happen to know if godaddy is setup this way? Is there a simple test I can do to find out? Sure, make sure that code is in your .htaccess file. test.html <?php echo 'If this doesn\'t have the word echo in front of it, PHP is parsed!'; ?> Edit: I MUST ESCAPE!!! Save the above box to a file, and call it with your browser.
  22. What version of PHP are you using? You could just write the GMT in there, it would have to be escaped though. echo 'time=' . date('D M j H:i:s \G\M\TO Y');
  23. The ampersand is what separates fields in a $_GET array. So the way that you have it written with ampersands is most likely not going to work. You could urlencode the URI, or you could use + signs.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.