rostros
-
Posts
10 -
Joined
-
Last visited
Never
Posts posted by rostros
-
-
Hi Guys , having a little trouble getting this code through W3 XHTML Validation , Im using a Dreamweaver Pagination extension which I know using extensions is bad but this is a big project. Im familar with the concept of using & rather than & but it appears it still does't work. Anyway here is the code.
-
PHP Code / Variable
$queryString_tbl_dealer_vehicles = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_tbl_dealer_vehicles") == false && stristr($param, "totalRows_tbl_dealer_vehicles") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_tbl_dealer_vehicles = "&" . htmlentities(implode("&", $newParams)); } } $queryString_tbl_dealer_vehicles = sprintf("&totalRows_tbl_dealer_vehicles=%d%s", $totalRows_tbl_dealer_vehicles, $queryString_tbl_dealer_vehicles);
XHTML Page Code
<?php for ($i=0; $i <= $totalPages_tbl_dealer_vehicles; $i++) { $TFM_PagesEndCount = $i + 1; if($i != $pageNum_tbl_dealer_vehicles) { printf('<a href="'."%s?pageNum_tbl_dealer_vehicles=%d%s", $currentPage, $i, $queryString_tbl_dealer_vehicles.'">'.$TFM_PagesEndCount."</a>"); }else{ echo(" [<strong>$TFM_PagesEndCount</strong>] "); } if($i != $totalPages_tbl_dealer_vehicles) echo(""); } ?>
XHTML Error
cannot generate system identifier for general entity "totalRows_tbl_dealer_vehicles"
…x.php?pageNum_tbl_dealer_vehicles=1&totalRows_tbl_dealer_vehicles=8">2</a>
--
It looks like the %s is the part where I need the & but this just gives more errors ? I hope someone can help me as I dont really want to code this site as non xhtml compliant.
Thanks
-
Ive just found a really good .PHP Script , thats is working great. (Please see below) it uses $_REQUEST to get the variables for the database which isn't really a problem because im going to get these variables called from an existing database, the only problem i have is the script outputs the .sql file as download , Ive noticed many scripts out there have the option of sending the .sql file or .gzip to an email address, I would like to get this script to automatically email the .sql file to me directly.
Ill be honest im not a hardcore programmer, im going to try and do it myself but if anyone would like to help I would be very greatfull , anyone who can sort this for me ill send them $10 via paypal,
--------------------------------------
<?php
/*---------------------------------------------------+
| mysqldump.php
+----------------------------------------------------+
| Copyright 2006 Huang Kai
| hkai@atutility.com
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------*/
/*
change log:
2006-10-16 Huang Kai
---------------------------------
initial release
2006-10-18 Huang Kai
---------------------------------
fixed bugs with delimiter
add paramter header to add field name as CSV file header.
2006-11-11 Huang Kia
Tested with IE and fixed the <button> to <input>
*/
$mysqldump_version="1.02";
$print_form=1;
$output_messages=array();
//test mysql connection
if( isset($_REQUEST['action']) )
{
$mysql_host=$_REQUEST['mysql_host'];
$mysql_database=$_REQUEST['mysql_database'];
$mysql_username=$_REQUEST['mysql_username'];
$mysql_password=$_REQUEST['mysql_password'];
if( 'Test Connection' == $_REQUEST['action'])
{
_mysql_test($mysql_host,$mysql_database, $mysql_username, $mysql_password);
}
else if( 'Export' == $_REQUEST['action'])
{
_mysql_test($mysql_host,$mysql_database, $mysql_username, $mysql_password);
if( 'SQL' == $_REQUEST['output_format'] )
{
$print_form=0;
//ob_start("ob_gzhandler");
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="'.$mysql_host."_".$mysql_database."_".date('YmdHis').'.sql"');
echo "/*mysqldump.php version $mysqldump_version */\n";
_mysqldump($mysql_database);
//header("Content-Length: ".ob_get_length());
//ob_end_flush();
}
else if( 'CSV' == $_REQUEST['output_format'] && isset($_REQUEST['mysql_table']))
{
$print_form=0;
ob_start("ob_gzhandler");
header('Content-type: text/comma-separated-values');
header('Content-Disposition: attachment; filename="'.$mysql_host."_".$mysql_database."_".$mysql_table."_".date('YmdHis').'.csv"');
//header('Content-type: text/plain');
_mysqldump_csv($_REQUEST['mysql_table']);
header("Content-Length: ".ob_get_length());
ob_end_flush();
}
}
}
function _mysqldump_csv($table)
{
$delimiter= ",";
if( isset($_REQUEST['csv_delimiter']))
$delimiter= $_REQUEST['csv_delimiter'];
if( 'Tab' == $delimiter)
$delimiter="\t";
$sql="select * from `$table`;";
$result=mysql_query($sql);
if( $result)
{
$num_rows= mysql_num_rows($result);
$num_fields= mysql_num_fields($result);
$i=0;
while( $i < $num_fields)
{
$meta= mysql_fetch_field($result, $i);
echo($meta->name);
if( $i < $num_fields-1)
echo "$delimiter";
$i++;
}
echo "\n";
if( $num_rows > 0)
{
while( $row= mysql_fetch_row($result))
{
for( $i=0; $i < $num_fields; $i++)
{
echo mysql_real_escape_string($row[$i]);
if( $i < $num_fields-1)
echo "$delimiter";
}
echo "\n";
}
}
}
mysql_free_result($result);
}
function _mysqldump($mysql_database)
{
$sql="show tables;";
$result= mysql_query($sql);
if( $result)
{
while( $row= mysql_fetch_row($result))
{
_mysqldump_table_structure($row[0]);
if( isset($_REQUEST['sql_table_data']))
{
_mysqldump_table_data($row[0]);
}
}
}
else
{
echo "/* no tables in $mysql_database */\n";
}
mysql_free_result($result);
}
function _mysqldump_table_structure($table)
{
echo "/* Table structure for table `$table` */\n";
if( isset($_REQUEST['sql_drop_table']))
{
echo "DROP TABLE IF EXISTS `$table`;\n\n";
}
if( isset($_REQUEST['sql_create_table']))
{
$sql="show create table `$table`; ";
$result=mysql_query($sql);
if( $result)
{
if($row= mysql_fetch_assoc($result))
{
echo $row['Create Table'].";\n\n";
}
}
mysql_free_result($result);
}
}
function _mysqldump_table_data($table)
{
$sql="select * from `$table`;";
$result=mysql_query($sql);
if( $result)
{
$num_rows= mysql_num_rows($result);
$num_fields= mysql_num_fields($result);
if( $num_rows > 0)
{
echo "/* dumping data for table `$table` */\n";
$field_type=array();
$i=0;
while( $i < $num_fields)
{
$meta= mysql_fetch_field($result, $i);
array_push($field_type, $meta->type);
$i++;
}
//print_r( $field_type);
echo "insert into `$table` values\n";
$index=0;
while( $row= mysql_fetch_row($result))
{
echo "(";
for( $i=0; $i < $num_fields; $i++)
{
if( is_null( $row[$i]))
echo "null";
else
{
switch( $field_type[$i])
{
case 'int':
echo $row[$i];
break;
case 'string':
case 'blob' :
default:
echo "'".mysql_real_escape_string($row[$i])."'";
}
}
if( $i < $num_fields-1)
echo ",";
}
echo ")";
if( $index < $num_rows-1)
echo ",";
else
echo ";";
echo "\n";
$index++;
}
}
}
mysql_free_result($result);
echo "\n";
}
function _mysql_test($mysql_host,$mysql_database, $mysql_username, $mysql_password)
{
global $output_messages;
$link = mysql_connect($mysql_host, $mysql_username, $mysql_password);
if (!$link)
{
array_push($output_messages, 'Could not connect: ' . mysql_error());
}
else
{
array_push ($output_messages,"Connected with MySQL server:$mysql_username@$mysql_host successfully");
$db_selected = mysql_select_db($mysql_database, $link);
if (!$db_selected)
{
array_push ($output_messages,'Can\'t use $mysql_database : ' . mysql_error());
}
else
array_push ($output_messages,"Connected with MySQL database:$mysql_database successfully");
}
}
if( $print_form >0 )
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>mysqldump.php version <?php echo $mysqldump_version; ?></title>
</head>
<body>
<?php
foreach ($output_messages as $message)
{
echo $message."<br />";
}
?>
<form action="" method="post">
MySQL connection parameters:
<table border="0">
<tr>
<td>Host:</td>
<td><input name="mysql_host" value="<?php if(isset($_REQUEST['mysql_host']))echo $_REQUEST['mysql_host']; else echo 'localhost';?>" /></td>
</tr>
<tr>
<td>Database:</td>
<td><input name="mysql_database" value="<?php echo $_REQUEST['mysql_database']; ?>" /></td>
</tr>
<tr>
<td>Username:</td>
<td><input name="mysql_username" value="<?php echo $_REQUEST['mysql_username']; ?>" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="mysql_password" value="<?php echo $_REQUEST['mysql_password']; ?>" /></td>
</tr>
<tr>
<td>Output format: </td>
<td>
<select name="output_format" >
<option value="SQL" <?php if( isset($_REQUEST['output_format']) && 'SQL' == $_REQUEST['output_format']) echo "selected";?> >SQL</option>
<option value="CSV" <?php if( isset($_REQUEST['output_format']) && 'CSV' == $_REQUEST['output_format']) echo "selected";?> >CSV</option>
</select>
</td>
</tr>
</table>
<input type="submit" name="action" value="Test Connection"><br />
<br>Dump options(SQL):
<table border="0">
<tr>
<td>Drop table statement: </td>
<td><input type="checkbox" name="sql_drop_table" <?php if(isset($_REQUEST['action']) && ! isset($_REQUEST['sql_drop_table'])) ; else echo 'checked' ?> /></td>
</tr>
<tr>
<td>Create table statement: </td>
<td><input type="checkbox" name="sql_create_table" <?php if(isset($_REQUEST['action']) && ! isset($_REQUEST['sql_create_table'])) ; else echo 'checked' ?> /></td>
</tr>
<tr>
<td>Table data: </td>
<td><input type="checkbox" name="sql_table_data" <?php if(isset($_REQUEST['action']) && ! isset($_REQUEST['sql_table_data'])) ; else echo 'checked' ?>/></td>
</tr>
</table>
<br>Dump options(CSV):
<table border="0">
<tr>
<td>Delimiter:</td>
<td><select name="csv_delimiter">
<option value="," <?php if( isset($_REQUEST['output_format']) && ',' == $_REQUEST['output_format']) echo "selected";?>>,</option>
<option value="Tab" <?php if( isset($_REQUEST['output_format']) && 'Tab' == $_REQUEST['output_format']) echo "selected";?>>Tab</option>
<option value="|" <?php if( isset($_REQUEST['output_format']) && '|' == $_REQUEST['output_format']) echo "selected";?>>|</option>
</select>
</td>
</tr>
<tr>
<td>Table:</td>
<td><input type="input" name="mysql_table" value="<?php echo $_REQUEST['mysql_table']; ?>" /></td>
</tr>
<tr>
<td>Header: </td>
<td><input type="checkbox" name="csv_header" <?php if(isset($_REQUEST['action']) && ! isset($_REQUEST['csv_header'])) ; else echo 'checked' ?>/></td>
</tr>
</table>
<input type="submit" name="action" value="Export"><br />
</form>
</body>
</html>
<?php
}
?>
------------------------------------------------------------------
-
Hey Guys , having a little issue with a form submit which im hoping someone has the answer to, anyone who can help me solve this I will give $10 via paypal.
I have been using Session Variables for sometimes in Dreamweaver, I dont really hand code that much to be honest, so thats why i need your help. I have quite a large form which has around 25 textfields, checkboxes and Drop Down fields etc, also mutiple file fields for photos, my current issue is that the user sometimes gets a Timeout when uploading the files, when the user uses the 'Back' button all data is lost. I know it is possible to store all information into session variables just when the user submits the form. I have looked at examples on this forum and the web but found only snipplets
Okay....What I really need !
An Example of a basic session, storing the variables to the Server as soon as User has press Submit on the <FORM>, it wouldn't really matter about IF Statments to check if the session exist's, if you could so an example that would be great.
$textfield
$checkbox
$dropdown
Please note that I have one .php file and not both html / php files.
-
Ok , thanks for your feedback.
Ill have a play around. -
Any way round it ?
-
[quote author=fenway link=topic=102773.msg408502#msg408502 date=1154561794]
Yes, but then you'd get a random filename!
[/quote]
Ok this is the table structure so far
[b]phpbb_attachments [/b]
[color=green]attach_id[/color]
[color=teal]post_id [/color]
[b]phpbb_attachments_desc[/b]
[color=green]attach_id[/color]
physical_filename
[b]phpbb_posts[/b]
[color=teal]post_id[/color]
[color=blue]topic_id[/color]
[b]phpbb_topics[/b]
[color=blue]topic_id[/color]
topic_filetime
topic_attachment
I Wish to Display all the topics with an attachment, with a single post_id , filetime also DESC to show the latest. From the above SQL i have been able to do this but I have mutiple post_id's because sometimes there is more than a couple of post's per topic.
physical_filename topic_id post_id topic_attachment topic_filetime
dscf_0045.jpg 5666 34444 1 (timestamp)
Img0067.jpg 5667 35544 1 (timestamp)
,
IF DISTINCT wont work would it be possible to create a function at end of the SQL like phpbb_post_id > 1 or something to always increment it somehow ?
-
[quote author=fenway link=topic=102773.msg408430#msg408430 date=1154554541]
You're right, you can't use DISTINCT for just one of N columns... however, if you use a GROUP BY (the proper way), you'll make any other column values from that table meaningless. Please explain.
[/quote]
How the board works at the moment is a user can post mutiple posts to one topic, im trying to create a overview of posted topics, including the filename taken from the very first post of each topic (e.g a preview of whats been posted in that topic), hence thats why DISTINCT would of been great to remove all the duplicates post_ids .
-
Okay, i am modding a phpbb database that has an attachment mod, i have had to connect 4 tables together which is the easy part, i have tried to use DISTINCT to remove duplicate post_id's but it doesn't work due to the number of tables im adding.
here is my SQL Query
SELECT phpbb_attachments_desc.attach_id, phpbb_attachments_desc.physical_filename, phpbb_attachments.attach_id, [color=red]phpbb_attachments.post_id[/color], phpbb_posts.post_id, phpbb_posts.topic_id, phpbb_topics.topic_id, phpbb_topics.forum_id, phpbb_topics.topic_time, phpbb_topics.topic_attachment
FROM phpbb_attachments_desc, phpbb_attachments, phpbb_posts, phpbb_topics
WHERE phpbb_attachments_desc.attach_id = phpbb_attachments.attach_id AND phpbb_attachments.post_id = phpbb_posts.post_id AND phpbb_posts.topic_id = phpbb_topics.topic_id AND phpbb_topics.topic_attachment = 1
ORDER BY phpbb_topics.topic_time DESC
What I Need is to remove these duplicate post_id's from the this query, as i want to show a preview of the attachment posted in the topic, please see attachment for screenshot.
Any help would be great. thanks
[attachment deleted by admin] -
Ive been using Dreamweaver for a while now and have been building dynamic sites with PHP / MySQL which is great fun but recently i have hit a break wall on a latest development.
This is the current issue where im stuck ,
In one table which contains these details
---------------------------------
vehicle_id
vehicle_manufacturer
vehicle_model
vehicle_added
----------------------------------
On my .PHP Page I have created a Form, with a List Box and created connection via MySQL to call all the Vehicles in this list.
Problem :
The List Box only contains either Manufacturer or Model Type not both at once, so I created another List Box in the Form so when the user selects the vehicle manufacturer it then filters the model dropdown box depending on the manufacturer.
I know there is way of using javascript to filter the options on selection but i wish to use the options stored in MySQL.
How do you program this Drop Down Box's that use MySQL Data, and how do you Filter them ? would you use $URL Variables or $FORM Variables or something different.
Any help would be great.
[SOLVED] Ampersands on Pagination in Dreamweaver XHTML Validating Issue
in PHP Coding Help
Posted
Okay quick fix managed to validate the code , if anybody is using Dreamweaver and you get the same problem just replace
With
Remove the &totalRows and replace it with "&" . totalRows_